Jump to content
Sign in to follow this  
thelbc

Exclude [shortcode] from the excerpt!

Recommended Posts

thelbc    0
thelbc

Me again, I wonder how I should remove the [shortcode] from my excerpt! I never use the excerpt field into the post... and let wordpress create them for me. So when I have a [shortcode] at the top of the post, this one is displayed into the excerpt. I found the solution here but I don't want to hardcode it into Platform Pro and would prefer to modify my child theme... Any advices?

Share this post


Link to post
Share on other sites
thelbc    0
thelbc

I tried this but it doesn't work!

function remove_shortcode_from_index($content) {
	  if ( is_home() ) {
	    $content = strip_shortcodes( $content );
	  }
	  return $content;
	}
	add_filter('the_excerpt', 'remove_shortcode_from_index');

Any help would be appreciated.

Share this post


Link to post
Share on other sites
Andrew    201
Andrew

My thoughts are that the filter should work. Double check the function 'strip_shortcodes'... or try some other functions there. (this will only work on your homepage/posts page fyi)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×