Make your category pages display post excerpts - EDUCATION FOR ALL

Random Posts

test banner

Breaking

Home Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Tuesday, September 4, 2012

Make your category pages display post excerpts


Most of the Category pages, just like search results or archives, are usually used for navigation purposes. While considering this fact it would make no sense to display full posts on those pages since the reader needs to be able to skim through a larger number of posts to decide what he wants to read.
For example if your WordPress theme is currently displaying full posts on the category or archive pages below. And if you want that how to change it and showing only the post excerpts or even the post titles.
For this purpose you will need first of all to locate the file inside your theme folder that is managing the category, archives and search pages. Most WordPress themes have that information inside the archive.php or archives.php file.
The file will look more or less like this:
<?php if (is_category()) { ?>
<h2 class='archives'>Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
<?php }
elseif (is_day()) { ?>
<h2 class='archives'>Archive for <?php the_time('F jS, Y'); ?></h2>

Once you find the file you will need to find where the Loop starts, usually with the following line:
<?php while (have_posts()) : the_post(); ?>
The information contained inside the Loop will govern the structure of the posts inside the mentioned pages (categories, archives, search results and so on). A couple of lines after the beginning of the Loop you will find the argument that includes the full posts on those pages:
<?php the_content(__('Read more »'));?>
In order to display the post excerpts you will need to substitute that line with the following:
<?php the_excerpt() ?>
If you want to display only the post titles (should be considered if you have a large number of posts on every category or on the archives) you can just eliminate that line altogether.
Finally, you may also want to remove the meta data (author, date or comments information) from those pages, which should be listed right after the post title or after the content line.

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages