How To Convert Category Pages To Post Titles In WordPress Blog

Posted by

Hi,

Many wordpress users wants to display Category Pages instead of Post titles. For that you need to perform these steps:

1) Open archive.php file of your theme.
2) Remove the code between the loops.

Loop starts at:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Loop End:
<?php endif; ?>

3) Add this code between the  loop:
<?php $temp_category = single_cat_title(”,false); if (!empty($temp_category)){ //
give index ?>
<h1><?php single_cat_title(); ?></h1>
<p><?php echo(category_description(the_category_ID(false))); ?></p>
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li><br>
<?php endforeach; else: ?>
<p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>
<?php endif; ?>
<?php }else{ // give details or single post ?>
…… code for normal post overview
<?php } ?>

4) Save and upload the file again on the server.

That’s it!

Thanks,

Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.