
「先頭に固定表示」記事を新着一覧先頭に表示させない
公開日:2014年10月28日
WordPressの新着一覧表示時、「先頭に固定表示」を無視して最新日付順に並び替えたいときの方法。
query_posts("ignore_sticky_posts=1");
query_postsの引数に「ignore_sticky_posts=1」を指定して「先頭に固定表示」を無視させて一覧情報取得。
記述例
//先頭に固定表示無視、最新5件分表示 $paged = get_query_var('paged'); query_posts("ignore_sticky_posts=1&posts_per_page=5&paged=$paged"); if ( have_posts() ) : while ( have_posts() ) : the_post(); //#01 テンプレートのフォーマット呼び出し get_template_part( 'content' ); endwhile; else : //記事がない時のテンプレート get_template_part( 'content', 'none' ); endif; ?>
同じカテゴリーのコンテンツ