0

I'm building a site on wp and can't seem to get over this obstacle, when I go to a specific category archive page, it shows all the posts from all the categories instead of just the ones in that category... Wondering if anyone has can help me figure out how to limit the results to show just the posts from the category called.

Here's my category.php

<?php get_header(); ?>
    <div class="row">
        <div class="span10">
            <div class="gridContainer">

                <?php
                    $the_query = new WP_Query( array( 
                    'post_type' => 'post',
                    'orderby' => 'date',
                    'order' => 'DESC',
                    'posts_per_page' => 999)); // how many posts to show
                     $x = 0;

                 while ( $the_query->have_posts() ) :
                 $the_query->the_post(); ?>
                <div class="view view-tenth"> 
                        <?php the_post_thumbnail('grid-image'); ?> 
                        <div class="mask"> 
                            <h2><?php the_title(); ?></h2> 
                            <p><?php the_excerpt(); ?></p> 
                             <a href="<?php the_permalink(); ?>" class="info">Take Me To The Porn!</a> 
                        </div> <!-- mask -->
                </div> <!-- view view-tenth -->

                    <?php $x++; ?>
                    <?php endwhile; ?>

                    <?php wp_reset_query(); ?>
                    <div class="clear"></div>

            </div> <!-- gridContainer -->

        </div> <!-- span10 -->

        <div class="span2">
            <?php get_template_part('sidebar'); ?>
        </div> <!-- span2 -->
    </div> <!-- row -->

<?php get_footer(); ?>
4

1 回答 1

1

由于您正在创建自己的 WP_Query,因此您必须精确使用您正在使用的实际过滤器。对于类别,请查看此处的相关文档:http: //codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

请注意,如果您正在修改 category.php 模板,那么您已经在 wordpress 循环中,您不需要指定自己的 WP_Query。您可以简单地使用

while(have_posts() ):
    ...
endwhile;

环形。我建议下载TwentyTwelve主题并观察其内部运作。

于 2013-07-06T00:14:19.537 回答