好吧,我有一个 wordpress 循环,我想从 2 个类别中查询帖子,我想显示类别之间的共同帖子......就像帖子“测试”属于“x”类别,也属于“类别” y" 这就是我要查询的内容。我试过类似的东西
<?php query_posts('cat=x&&cat=y'); ?>
但这带来了两个类别的帖子,而不是重叠的帖子......提前致谢。
好吧,我有一个 wordpress 循环,我想从 2 个类别中查询帖子,我想显示类别之间的共同帖子......就像帖子“测试”属于“x”类别,也属于“类别” y" 这就是我要查询的内容。我试过类似的东西
<?php query_posts('cat=x&&cat=y'); ?>
但这带来了两个类别的帖子,而不是重叠的帖子......提前致谢。
你需要使用这个
query_posts( array( 'category__and' => array(x,y));
其中 x 和 y 是类别的 id
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 »', '1 Comment »', '% Comments »'); ?></p>
<div class="entry-content">
<?php the_content('Read the rest of this entry »'); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'redlust' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
</div>
<?php endwhile; ?>