Lot of Users Searching how to display Post Excerpts in WordPress themes. Here the simple tutorial that anyone can implement and take advantage of this built-in feature. By implementing this tutorial increase the page load speed and view count. Post Excerpt simply show a mini description of the article and let user view the post on single post page.
Open your index.php file, archive.php file, and category.php file. Now some of you might not have all these files in your template, so just open the ones that you do have.
Find the following code:
<?php the_content(); ?>
And replace it with:
<?php the_excerpt(); ?>
Now you can write custom excerpts for your posts from your WordPress admin panel and have it displayed in your theme.
If you do not write a custom excerpt, then WordPress automatically takes the first 55 words from your post and put them in an excerpt with elipses and display it. You can change the word limit starting from WordPress 2.9. If you want to change the word limit open your functions.php file and add the following function:
// Changing excerpt length function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); // Changing excerpt more function new_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more');
Recent Comments