dポイントプレゼントキャンペーン実施中!

ワードプレスで、あるカテゴリの記事の、サムネイル一覧を表示させようと思っています。

<?php
$paged = (int) get_query_var('paged');
$args = array(
'posts_per_page' => 9,
'category' => '11',
//'paged' => $paged,
//'orderby' => 'post_date',
//'order' => 'DESC',
//'post_type' => 'post',
//'post_status' => 'publish'
);

$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
?>

<li>
<?php the_post_thumbnail('rel_tmn', array('alt'=>get_the_title(), 'title'=>get_the_title())); ?>
<a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"></a>
<?php if( function_exists('zilla_likes') ) zilla_likes(); ?>
</li>

<?php endwhile; endif; ?>

</ul>


カテゴリID「11」を指定しているのですが、全記事表示されてしまいます。

PHPに関してほとんど知識がないので、他のサイトからコードをコピーして貼り付けています。
どこを直せばいいのかわかるかた教えていただけますでしょうか。

A 回答 (1件)

ソースの5行目


'category' => '11',

ですがIDで指定する場合「category」ではなく「cat」のようですよ。
引用符の中をcatに変えて試してみてください。
    • good
    • 0
この回答へのお礼

早速のご回答ありがとうございます!catに変更したらカテゴリ指定できました!本当にありがとうございます!

お礼日時:2017/10/04 15:28

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!