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?
-
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.– RarstCommented Sep 5, 2011 at 11:34
Add a 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.
-
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?– MorhausCommented Sep 5, 2011 at 0:19
-
3to overcome that single page behaviour: codex.wordpress.org/…– MichaelCommented Sep 5, 2011 at 9:02
- Try Advanced Excepts plugin,it's working perfectly.
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.