1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[GET] How To Show Only Post Titles in Category [WordPress]

Discussion in 'Blogging' started by ddederick, Oct 13, 2013.

  1. ddederick

    ddederick Jr. VIP Jr. VIP Premium Member

    Joined:
    Nov 22, 2012
    Messages:
    584
    Likes Received:
    432
    Location:
    The Source Code
    Hi guys,
    because I've been trying to do this for few hours I think it would be nice to share with you how to do it in no time.

    So, if you want to show only post titles in category and not all the post content:

    1. Go to the folder of template you're actually using.
    2. Open the file archive.php
    3. Find this:
    Code:
    [COLOR=#ffffff][FONT=Courier New]<?php if (have_posts()) : while (have_posts()) : the_post(); ?>[/FONT][/COLOR]
    4. Then remove everything what is after this and before the end of the cycle. (Image below)
    5. Now replace the removed code with this:
    Code:
    [COLOR=#ffffff][FONT=Courier New]<?php $temp_category = single_cat_title('',false); if (!empty($temp_category)){ // give index ?>[/FONT]
    [FONT=Courier New]<h1><?php single_cat_title(); ?></h1>[/FONT]
    [FONT=Courier New]<p><?php echo(category_description(the_category_ID(false))); ?></p>[/FONT]
    [FONT=Courier New]<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>[/FONT]
    [FONT=Courier New]<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li><br>[/FONT]
    [FONT=Courier New]<?php endforeach; else: ?>[/FONT]
    [FONT=Courier New]<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>[/FONT]
    [FONT=Courier New]<?php endif; ?>[/FONT]
    [FONT=Courier New]<?php }else{ // give details or single post ?>[/FONT]
    [FONT=Courier New]...... code for normal post overview[/FONT]
    [FONT=Courier New]<?php } ?>[/FONT][/COLOR]
    It will look like this:

    [​IMG]

    Done. Mission completed. :D
    Now upload it to the template folder on your server.

    I'm not author of the code. But hey, it took me ages to find it.
     
    • Thanks Thanks x 3
  2. petrovski

    petrovski Regular Member

    Joined:
    Nov 16, 2012
    Messages:
    265
    Likes Received:
    164
    Occupation:
    Outsource extrodinaire
    Location:
    Between a rock and a hard place
    Thanks for that share.. I will be sure to implement this...
     
    • Thanks Thanks x 1