0

I am new in Wordpress and I am trying to customize my own theme.

All my posts are starting with a kind of content that I don't want to become the excerpt. It is kind of header.

Is there a way to use as excerpt only content with class .myOnwnExcerpt, or maybe it will be easier to ask wordpress to run excerpt rule excluding text with class .notToBeDisplayedAsExcerpt. Thanks for any suggestions.

1
  • 2
    Easiest is to set manual excerpts. Commented Jun 15, 2015 at 9:53

1 Answer 1

2

The easiest course of action would be to write manual excerpts instead of having the system generate them.

Second, would be to wrap your "content that isn't an excerpt" in a shortcode. If you look at the wp_trim_excerpt() function, which generates excerpts from post content, one of the first thing it does is strip shortcodes. For example, if you had a shortcode like this:

function foocode($atts,$content){
  return $content;
}
add_shortcode('foo','foocode');

Anything in the post body such as [foo]Hello[/foo] would not appear in the generated excerpts. Note that the "exceprt" is not necessarily the chunk of text that displays on the index page. If the the theme uses the_content() the post content will break on the <!-- more --> tag, or nothing at all, and your content will still appear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.