-1

For development of my custom template, I need to show only a intro text of some posts.

Can you help me how to achieve that?

More informations:

As we all know, single WP post is defined as:

This is post's introducion text
<!--more-->
Main post content, blah blah blah

All I need is somehow to display

This is post's introducion text

... on frontend.

  • Please clarify what it is that you want, what you have tried so far, where you are stuck etc. Currently, it is not clear what you are trying to do. – tfrommen Feb 12 '14 at 11:19
  • Your question is not clear. Please add more details to it. If possible add examples – Maruti Mohanty Feb 12 '14 at 11:19
  • You mean you want excerpts on archive pages linking to the full posts? – Brad Dalton Feb 12 '14 at 11:26
  • yes. but with using the_excerpt() i'm getting whole post content – user198003 Feb 12 '14 at 11:56
  • review codex.wordpress.org/Function_Reference/… – Michael Feb 12 '14 at 12:36
1

While I am sure that the logic of what I am about to post is too simple, I think it should get you started.

Your terminology is odd but what it seems you want is to display the "post before the more" part of the post body. To do that, you need to break the post content into "post before the more" and "post after the more". There is a function for that.

$pieces = get_extended($post->post_content);
// var_dump($pieces); // debug
echo apply_filters('the_content',$pieces['main']);

Inside a Loop, that should work just fine. In other contexts you may need something other than $post->post_content.

Excerpts, manually or automatically created, will not come into play so you may need to include that in the logic.

  • tnx! i made it also with <?php global $more;$more = 0;the_content("Read more..."); ?>, but i like your solution too – user198003 Feb 13 '14 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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