WordPress「Sticky Posts」がカスタム投稿で表示されない
こちらで質問させて頂きましたが、Sticky Postsの機能を使うために、
get_postsからWP_Queryに直しています。
WP_Queryに変更したところ、アーカイブページでカテゴリ(カスタムタクソノミー)が反映されなくなっており、
Sticky Postsで先頭表示を指定したもの以外は全て新着順で掲載されています。
改善方法をご教授頂けないでしょうか。
<?php $the_query = new WP_Query(array( 'post_type' => array('introduce') ));?> <?php if ( $the_query->have_posts() ) : ?> <div id="introduce_list"> <div class="introduce_list_row clearfix"> <?php $i = 0; $row = 0; while ( $the_query->have_posts() ) : $the_query->the_post(); if ($i > 0 && $i % 3 == 0) { $row++; ?> </div> <div class="introduce_list_row clearfix"> <?php } $col_class = ''; if ($row % 2 == 0) { if ($i % 3 == 0) { $col_class = ' show_info'; } } else { if ($i % 3 == 2) { $col_class = ' show_info'; } } ?> <div class="introduce_list_col article inview-fadein<?php echo esc_attr($col_class); ?>"> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" class="clearfix"> <div class="image"> <?php if (has_post_thumbnail()) { the_post_thumbnail('size3'); } else { ?><img src="<?php echo get_template_directory_uri(); ?>/img/common/no_image3.gif" title="" alt="" /><?php } ?> </div> <div class="info"> <?php if ($dp_options['show_introduce_categories']) { $metas = array(); foreach(explode('-', $dp_options['show_introduce_categories']) as $cat) { if (!empty($dp_options['use_introduce_category'.$cat])) { $terms = get_the_terms($post->ID, $dp_options['introduce_category'.$cat.'_slug']); if ($terms && !is_wp_error($terms)) { $term = array_shift($terms); $metas[] = '<li class="cat"><span class="cat-'.esc_attr($dp_options['introduce_category'.$cat.'_slug']).'" data-href="'.get_term_link($term).'" title="'.esc_attr($term->name).'">'.esc_html($term->name).'</span></li>'; } } } if ($metas) { echo '<ul class="meta clearfix">'.implode('', $metas).'</ul>'; } } ?> <h3 class="title"><?php trim_title(32); ?></h3> <p class="excerpt"><?php new_excerpt(148); ?></p> <p class="more"><?php _e('Read more', 'tcd-w'); ?></p> </div> </a> </div> <?php $i++; endwhile; ?> <?php wp_reset_postdata(); ?> </div> </div>
あなたの回答
tips
プレビュー