Php wordpress上的自定义查询

Php wordpress上的自定义查询,php,content-management-system,posts,wordpress,Php,Content Management System,Posts,Wordpress,我有一个wordpress循环,我想从两个类别中查询帖子,我想显示类别之间的常见帖子。。。 比如,如果post“test”属于类别“x”,也属于类别“y”,这就是我想要查询的。 我试过类似的方法 <?php query_posts('cat=x&&cat=y'); ?> 但这带来了来自两个类别的帖子,而不是重叠的帖子。。。 提前感谢。cat=267将是您选择类别的地方,但您必须有一个循环才能将帖子放入页面中 <?php query_

我有一个wordpress循环,我想从两个类别中查询帖子,我想显示类别之间的常见帖子。。。 比如,如果post“test”属于类别“x”,也属于类别“y”,这就是我想要查询的。 我试过类似的方法

            <?php query_posts('cat=x&&cat=y'); ?>

但这带来了来自两个类别的帖子,而不是重叠的帖子。。。
提前感谢。

cat=267将是您选择类别的地方,但您必须有一个循环才能将帖子放入页面中

<?php query_posts('cat=267') ?>
        <?php while (have_posts()) : the_post(); ?>

            <div id="post" <?php post_class(); ?>>

                <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php edit_post_link( __( 'Edit', 'redlust' ), '<span class="edit-link">', '</span>' ); ?></h2>
                <p class="post-meta">Posted in <?php the_category(', ') ?>, on <?php the_time('F jS, Y'); ?>, by <?php the_author_meta(display_name); ?> <strong>|</strong> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
                    <div class="entry-content">
                        <?php the_content('Read the rest of this entry &raquo;'); ?>
                        <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'redlust' ), 'after' => '</div>' ) ); ?>
                    </div><!-- .entry-content -->
            </div>

        <?php endwhile; ?>

你需要用这个

query_posts( array( 'category__and' => array(x,y));
其中x和y是类别的id