Home Forums WoodMart support forum woodmart excerpts on blog archive showing elementor code

woodmart excerpts on blog archive showing elementor code

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #389482

    hollistergj
    Participant

    Blog archive is showing excerpts but they are showing elementor shortcode in the excerpt.
    When I turn use twenty-twenty theme it does not show that code.
    When I go back to woodmart, it shows up again.
    I have turned off all other plugins not included with woodmart and done all the latest upgrades for WP, woocommerce and all other plugins.
    How do I get the code to not show up in excerpts?

    #389527

    Luke Nielsen
    Keymaster

    Hello,

    Could you provide login access for your site’s WordPress admin panel? So we can log in and check what is wrong on your side.

    I await your response.

    Kind Regards

    #391848

    hollistergj
    Participant

    sure

    #391991

    Luke Nielsen
    Keymaster

    Hello,

    Sorry, but the admin details are incorrect, please update it and let me know.

    https://gyazo.com/cb4228e7c14cf5cfc91524624f46089a

    Looking forward to hearing back from you!

    Kind Regards

    #392128

    hollistergj
    Participant

    ok

    #392360

    Luke Nielsen
    Keymaster

    Hello,

    Please send us your FTP access to your server files so we can check what is wrong with your website. We will do our best to help you.

    Kind Regards

    #392422

    hollistergj
    Participant

    thanks

    #392783

    Luke Nielsen
    Keymaster

    Hello,

    You can sort it out with the below code, enter it into the functions.php file in your child theme.

    if( ! function_exists( 'woodmart_excerpt_from_content' ) ) {
    	function woodmart_excerpt_from_content($post_content, $limit, $shortcodes = '') {
    		// Strip shortcodes and HTML tags
    		if ( empty( $shortcodes )) {
    			$post_content = preg_replace("/\[caption(.*)\[\/caption\]/i", '', $post_content);
    			$post_content = preg_replace('\[[^\]]*\]','',$post_content);
    		}
    
    		$post_content = stripslashes( wp_strip_all_tags( $post_content ) );
    
    		if ( woodmart_get_opt( 'blog_words_or_letters' ) == 'letter' ) {
    			$excerpt = mb_substr( $post_content, 0, $limit );
    			if ( mb_strlen( $excerpt ) >= $limit ) {
    				$excerpt .= '...';
    			}
    		}else{
    			$limit++;
    			$excerpt = explode(' ', $post_content, $limit);
    			if ( count( $excerpt) >= $limit ) {
    				array_pop( $excerpt );
    				$excerpt = implode( " ", $excerpt ) . '...';
    			} else {
    				$excerpt = implode( " ", $excerpt );
    			}
    		}
    
    		$excerpt = strip_tags( $excerpt );
    
    		if ( trim( $excerpt ) == '...' ) {
    			return '';
    		}
    
    		return $excerpt;
    	}
    }

    Please let me know if you have any further questions in the meantime.

    Kind Regards

    • This reply was modified 2 years, 4 months ago by Luke Nielsen.
    • This reply was modified 2 years, 4 months ago by Luke Nielsen.
    • This reply was modified 2 years, 4 months ago by Luke Nielsen.
    #393432

    hollistergj
    Participant

    Thanks so much.
    Unfortunately, that didn’t seem to work, I pasted your code in and I’m getting this error message on the excerpts now:
    Warning: preg_replace(): Unknown modifier '\' in /home/vieracleartech/public_html/wp-content/themes/woodmart-child/functions.php on line 15

    this is line 15 in your code:
    $post_content = preg_replace('<code>\[[^\]]*\]</code>','',$post_content);

    This also didn’t have an effect on the HTML block shortcode being used in the category description. It’s still showing as just the shortcode, not the content of it.

    #393572

    Luke Nielsen
    Keymaster

    Hello,

    The issue has been fixed on your website so now it appears well.

    https://gyazo.com/2e807f29bc04034051731a346cd44509

    If you’d like to contact us, we are here for whatever questions you may have.

    Kind Regards

    #398832

    Franjuju
    Participant

    Hi, I have exactly the same problem with the same error message. Can you provide the corrected version of the code to copy please?

    Thank you!

    #398833

    Franjuju
    Participant

    Just fixed it:

    if( ! function_exists( 'woodmart_excerpt_from_content' ) ) {
    	function woodmart_excerpt_from_content($post_content, $limit, $shortcodes = '') {
    		// Strip shortcodes and HTML tags
    		if ( empty( $shortcodes )) {
    			$post_content = preg_replace("/\[caption(.*)\[\/caption\]/i", '', $post_content);
    			$post_content = preg_replace('/\[[^\]]*\]/i','',$post_content);
    		}
    
    		$post_content = stripslashes( wp_strip_all_tags( $post_content ) );
    
    		if ( woodmart_get_opt( 'blog_words_or_letters' ) == 'letter' ) {
    			$excerpt = mb_substr( $post_content, 0, $limit );
    			if ( mb_strlen( $excerpt ) >= $limit ) {
    				$excerpt .= '...';
    			}
    		}else{
    			$limit++;
    			$excerpt = explode(' ', $post_content, $limit);
    			if ( count( $excerpt) >= $limit ) {
    				array_pop( $excerpt );
    				$excerpt = implode( " ", $excerpt ) . '...';
    			} else {
    				$excerpt = implode( " ", $excerpt );
    			}
    		}
    
    		$excerpt = strip_tags( $excerpt );
    
    		if ( trim( $excerpt ) == '...' ) {
    			return '';
    		}
    
    		return $excerpt;
    	}
    }
    #398956

    Luke Nielsen
    Keymaster

    Hello,

    Glad that you manage to sort this out.

    Always remember that you can reach out to us with any questions you may have.

    We wish you a splendid day!

    Kind Regards

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘woodmart excerpts on blog archive showing elementor code’ is closed to new replies.