0

次のコードは、投稿タイトルのリストを出力します。このリストの下には、カテゴリ8にあるタグ「test」に一致する各完全な投稿も出力されます。なぜ完全な投稿が出力されるのですか?どうすればそれを防ぐことができますか?

$query_str = "cat=8&tag=test";
query_posts($query_str);

while ( have_posts() ) : the_post();
   echo '<div><a href="';
    the_permalink();
    echo '">';
    the_title();
    echo '</a></div>';
endwhile;
4

1 に答える 1

1

このようにquery_posts誤った使用法を使用する代わりに、サイズについてこれを試してくださいWP_Query

$args = array('cat' => 8, 'tag' => 'test');

$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<div><a href="'. get_permalink($the_query->post->ID).'"/>' . get_the_title() . '</a></div>';
endwhile;


wp_reset_postdata();
于 2013-03-15T15:35:58.413 に答える