0

On my archive page, the_excerpt() does not display content before the more tag, but a cut of the post's full content. I'm obliged to fulfill the "Excerpt" in the post editor which will override it. How to force the_excerpt() to show only the content before the more tag?

1
  • Could you provide some example? Of what posts starts with, where is more tag, what you expect to get as generated excerpt and what you actually get? WordPress should do what you want as I understand it, which makes me think I am not understanding question correctly.
    – Rarst
    Commented Sep 5, 2011 at 11:34

2 Answers 2

1

Why not just switch out the_excerpt for the_content in your theme? Or create a child theme and override the relevant files.

http://codex.wordpress.org/Child_Themes

2
  • Well, I just saw that the_content and the_excerpt just ignore the <-- more --> tag when the display page is supposed to be a single one. My archive is set on a page with a special template, so it just behaves like if it was a single page beeing displayed... Could a child theme override that behavior? My goal is to have an archive page for the post type 'post', like a page called "archive-{post-type}.php". Is there any way I can get to the same result whithout using a page template?
    – Morhaus
    Commented Sep 5, 2011 at 0:19
  • 3
    to overcome that single page behaviour: codex.wordpress.org/…
    – Michael
    Commented Sep 5, 2011 at 9:02
1

or add the following function to functions.php:

add_filter('the_excerpt','my_excerpt');
function my_excerpt(){
 global $post;
$link='<a class="more" href='.get_permalink($post->ID ).'>Read More...</a>';
$excerpt=get_the_excerpt($post->ID);
echo $excerpt.$link;
return true;
}

the previous function appends the perma link of the post to the excerpt,we used the filter the_excerpt so that when we use the_excerpts(); it results our customized excerpt.

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.