前提・実現したいこと
ここに質問の内容を詳しく書いてください。
WPのアーカイブページについて
発生している問題
アーカイブページで、 よくある特定カテゴリの一覧ページを作成しています。 カテゴリ名:gallery ターム:gallery_category 上記の中から 特定のスラッグのみの処理をしたいのですが、 どのようにしたら良いでしょうか? スラッグ:attention
該当のソースコード
<?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array( 'paged' => $paged , 'post_type' => 'gallery', 'posts_per_page' => 15, 'orderby' => array( 'menu_order' => 'DESC','date' => 'ASC' ), ); $the_query = new WP_Query($args); ?> <?php if($the_query->have_posts()): ?> <?php while($the_query->have_posts()) : $the_query->the_post(); ?> <?php $terms = get_the_terms($post->ID, 'gallery_category'); $term_name = $terms[0]->name; $term_slug = $terms[0]->slug; $term_id = $terms[0]->term_id; $term_link = get_term_link($term_id); ?> ----------------------- 特定したい条件・・・↓これがだめですよね・・? <?php if ( is_object_in_term($post->ID, 'gallery','attention') ): ?> <object><a class="tx-icon cat-<?php echo $term_id;?>"><?php echo $term_name;?></a></object> <?php endif;?>
補足情報(FW/ツールのバージョンなど)
お力添えをよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー