• Resolved Rose

    (@eos-rose)


    I’ve just added categories to my site, but I don’t have a categories.php file in my template folder. I DO have an archives.php file, which calls up ALL posts. When I view a category page, it will display all posts, not just the posts in that category (though when I click the “next page” button on a category page that doesn’t have enough posts to actually have a next page, I get an error).

    I’m not sure if I messed up the template somewhere along the line or if it never worked. What I need to know is how to limit the posts displayed to the specific category without having to create a bunch of category-ID.php files. I’m assuming I’ll probably have to create a category.php file? But what code do I need to use to make it work?

Viewing 1 replies (of 1 total)
  • Thread Starter Rose

    (@eos-rose)

    It just occurred to me that I’m thinking about this incorrectly. I’m pretty sure whatever is wrong must be somewhere in my code that is intended to display my posts in a 3-column table:

    <table class="results">
    
    <?php
    // Show a selected number of posts per row
    $posts_per_row = 3;
    $posts_per_page = 12;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
       'posts_per_page' => $posts_per_page,
       'paged' => $paged,
    );
    query_posts($args);
    if (have_posts()) {
       while (have_posts()) {
          the_post();
          if ((++$post_counter % $posts_per_row) == 1  || $posts_per_row == 1) {
             if ($post_counter > 1) {
                echo "</tr><!-- End of post_row -->";  // End previous row
             }
             echo "<tr>";  // Start a new row
          }
          echo "<td class=result>";  // Start one post
             // Output post data here
    
    echo '<span class=date>Released ';the_time('F j, Y');echo ' at ';the_time();echo '</span>';
             echo '<h1><a href="';the_permalink();echo '">';the_title();echo '</a></h1>';
    if (get_post_meta($post->ID, 'author', false)) {
    echo '<blockquote>written by ';$metas = get_post_meta($post->ID,'author',false);
       if(count($metas) >1) { echo 'Multiple Authors'; }
    else { echo $metas[0]; }
    echo '<br />'; }
    
    if(get_post_meta($post->ID, 'summary', true)) { echo '<blockquote>';echo get_post_meta($post->ID, 'summary', true); echo '</blockquote>'; }
    
    }
    
          echo "</td><!-- End of post_class -->";  // End of post
       } ?>
    
       <!-- End of post_row -->
    
    <?php } else {
       // Code for no posts found
    echo "<tr><td colspan=3><p>No posts found.</p></td></tr>";
    }
    ?>
    </table>

    Any idea where the problem is?

Viewing 1 replies (of 1 total)
  • The topic ‘Category pages showing ALL posts rather than specific category…’ is closed to new replies.