Jump to content


Photo

Exclude [shortcode] from the excerpt!


This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 thelbc

thelbc

    Member

  • Members
  • PipPip
  • 13 posts

Posted 20 October 2010 - 03:54 PM

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?

#2 thelbc

thelbc

    Member

  • Members
  • PipPip
  • 13 posts

Posted 20 October 2010 - 04:10 PM

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.

#3 arpowers

arpowers

    Founder

  • Administrators
  • 3271 posts

Posted 20 October 2010 - 05:27 PM

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)