Modifying the Loop for category templates
-
Forgive me, folks, I probably have NO idea what I’m talking about…
So I’m using the Coraline theme and creating a child theme to make various modifications to it.
I need to create several category templates that display all the posts in that category BY TITLE ONLY with no other information. (It’s a recipe blog, I just want the titles of the recipes on the DESSERTS page, for example. You click on the title of the recipe, it takes you to the single post page of the recipe.)
There is a wealth of information about how to do this, however, all the info seems to be for previous versions where the loop was included in each template. Now the loop only resides in loop.php. So none of the information I’m finding applies to my version. This is the code for the category.php file in Coraline:
<div id="content-container"> <div id="content" role="main"> <h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'coraline' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1> <?php $category_description = category_description(); if ( ! empty( $category_description ) ) echo '<div class="archive-meta">' . $category_description . '</div>'; get_template_part( 'loop', 'category' ); ?> </div><!-- #content --> </div><!-- #content-container -->
I know that, in order to show the title of the post only, I need to remove
<?php the_content() ?>
the_permalink the_excerpt, etc. However…these things do not exist in the template.I know that I need to add
<?php query_posts('posts_per_page=1000'); ?>
in order to ensure that I have every post in the category showing on one page, but since there’s no loop, I’m not sure where to add that.So I guess my basic question is…how do you create a category-slug template in the NEW wordpress if I need to modify the loop to list only post titles, and to list every post title within that category? Do I have to modify loop.php? And if I do, can I have a child loop.php that will override the parent loop.php in the Coraline folder?
This quickly got far too advanced for me…if I was working on an older version of WP it’d be a piece of cake using the examples I’ve found…but none of the examples apply because the loop code is no longer inside each template.
- The topic ‘Modifying the Loop for category templates’ is closed to new replies.