1

I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the first part of a post, but I'd like to change that so it shows the whole thing.

In the Category Template (category.php) file, there are a few lines of code that look like they are responsible for generating the category data:

/* Run the loop for the category page to output the posts.
 * If you want to overload this in a child theme then include a file
 * called loop-category.php and that will be used instead.
 */
get_template_part( 'loop', 'category' );
?>

Since the comments mention setting up a child theme, I went ahead and followed these instructions (via this answer) to set up a child theme so I could add my custom functionality.

I see from the comments that I'm supposed to create a file called loop-category.php with my custom implementation, but I don't know what code I need to put in that file. What do I need to add to loop-category.php to get Category views to show up with full blog posts?

NOTE: While I've been using Wordpress for quite a while, this is my first dive into theme customization. Any help would be much appreciated.

1
  • any one good experience select category php ? [email protected] yahoo masseger contact me
    – user49348
    Commented Mar 23, 2014 at 0:53

2 Answers 2

7

@Ben,

If you look at line 132 of loop.php in Twentyten you will find the conditional statement that is telling WordPress to only display the_excerpt on category archives. Right below that after <?php else : ?> is how all posts that are not on an archive page, in the asides category or in the gallery category will be displayed. (The asides and gallery categories are targeted at the beginning of loop.php)

<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
            <div class="entry-summary">
                <?php the_excerpt(); ?>
            </div><!-- .entry-summary -->
    <?php else : ?>
            <div class="entry-content">
                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
                <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
            </div><!-- .entry-content -->
    <?php endif; ?>

In your loop-category.php file the easiest thing to do would be copy and paste the whole loop.php file and change the section of code above to:

<?php if ( is_search() ) : // Only display excerpts for archives and search. ?>
            <div class="entry-summary">
                <?php the_excerpt(); ?>
            </div><!-- .entry-summary -->
    <?php else : ?>
            <div class="entry-content">
                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
                <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
            </div><!-- .entry-content -->
    <?php endif; ?>

You will notice that we only removed is_archive from the conditional statement so now category archives will displayed using the code after the else statement which contains the_content as opposed to the_excerpt.

3
  • that's really cool; it worked perfectly! i didn't realize at first that I would be copying the entire contents of loop.php into loop-category.php. I think I'm starting to get how child themes work and it's a pretty cool concept. Commented Sep 19, 2010 at 3:32
  • We could have just changed it in loop.php but it would be overwritten the next time an update gets released.
    – Chris_O
    Commented Sep 19, 2010 at 4:14
  • Could customize loop.php just as well - files in child theme are not overwritten by updates of parent theme (that's kinda the point :). Also if using loop-category.php then conditional if ( is_search() )... can be dropped completely, because this loop will only be called on category pages anyway.
    – Rarst
    Commented Sep 19, 2010 at 8:31
1

I just removed the second instance of "is_archive() || " from loop.php and got each entire post to show up on the category/catslug page. I didn't have to create a loop-category.php file. I couldn't have done it with out Chris_O's instructions. Thanks, Chris!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.