Tag:トップページ ( 1 Posts)

「先頭に固定表示」を反映しない

クライアントからの要望で先頭に固定表示をカテゴリページに反映する必要があり、前回そのカスタマイズを行いましたが、それにより今度はトップページに表示してあった新着情報の部分は「先頭に固定表示」を無効にする必要が出てきました。

先頭に固定表示は元々はトップページで「のみ」有効になる機能です。



index.phpまたはトップページのテーマファイルの該当箇所で、query_posts()の条件に'ignore_sticky_posts' => '1'を加えます。
例)
<?php 
$args = array(
	'posts_per_page' => 5,
	'ignore_sticky_posts' => 1,
);
$the_query = new WP_Query( $args );?>

<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();?>
	<!-- 表示処理 -->
	<p><?php the_time('Y/n/j'); ?></p>
	<p><?php the_title(); ?></p>
<?php endwhile; endif; ?>