Archived

This topic is now archived and is closed to further replies.

  • 0

Exclude [shortcode] from the excerpt!

Question

Posted · Report post

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

2 answers to this question

Posted · Report post

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

Posted · Report post

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