###前提・実現したいこと
Wordpress初心者です。
カスタム投稿タイプの記事一覧の一部を取得して表示
したいです。
この記事を参考に
https://increment-log.com/custom-post-list/
ポストタイプ、information
カテゴリID、2の記事だけを表示させたいのですができません。
###該当のソースコード
<ul> <?php $args = array( 'numberposts' => 5, //表示(取得)する記事の数 'post_type' => 'information',//投稿タイプの指定 'category' => 2 ); $posts = get_posts( $args ); if( $posts ) : foreach( $posts as $post ) : setup_postdata( $post ); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> <?php else : //記事が無い場合 ?> <li><p>記事はまだありません。</p></li> <?php endif; wp_reset_postdata(); //クエリのリセット ?> </ul>
###試したこと
'post_type' => 'information のみの記載ならinformation全体の記事が表示されるのですが
'category' => 2
を足すと
記事はまだありません。 と表示されてしまいます。
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
WordPress 4.8です。
回答1件
あなたの回答
tips
プレビュー