###やりたいこと
表題の通りです。
例:
記事1←必ず一番上に表示されてほしい
記事ランダム1←ランダムに表示
記事ランダム2←ランダムに表示
記事ランダム3←ランダムに表示
記事ランダム4←ランダムに表示
記事ランダム5←ランダムに表示
###やってみたソース
<?php $wp_query = new WP_Query(); $param = array( 'post_type' => 'office', 'post_status' => 'publish', 'category__and' => array('170'), //必ずトップに表示させたい記事のカテゴリ 'tax_query' => array( 'relation' => 'AND', $tax_array ), ); $wp_query->query($param); if($wp_query->have_posts()): while($wp_query->have_posts()) : $wp_query->the_post();?> <?php get_template_part('templates/property_unit');; ?> <?php endwhile; endif; ?> <?php $wp_query = new WP_Query(); remove_all_filters('posts_orderby'); $param = array( 'post_type' => 'office', 'post_status' => 'publish', 'orderby' => 'rand', //ランダムに表示させたい残りの記事 'category__not_in' => array('170'), 'tax_query' => array( 'relation' => 'AND', $tax_array ), ); $wp_query->query($param); if($wp_query->have_posts()): while($wp_query->have_posts()) : $wp_query->the_post();?> <?php get_template_part('templates/property_unit');; ?> <?php endwhile; endif; ?>
###問題
これだと次のページに行くと毎回1ページ目のトップに表示された記事が表示されてしまう。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/09 08:01
2016/06/09 08:07