Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 Sep 5 '11 at 11:34
add comment

2 Answers

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

share|improve this answer
    
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 Sep 5 '11 at 0:19
2  
to overcome that single page behaviour: codex.wordpress.org/… –  Michael Sep 5 '11 at 9:02
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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