TwentyTen アーカイブ(年月別)ページの表示件数を個別に設定する

ワードプレステーマTwentyTenのアーカイブ(年月別)ページの記事表示件数を個別に設定する方法です。

デフォルトですと、「表示設定」の記事表示件数に依存します。それでは都合があまりよろしくないので、個別に表示件数を設定したいと思います。

それでは、テンプレートファイルの中から’archive.php’(アーカイブ)ファイルを開いて下さい。(小テーマを使用している方は、小テーマ側のテンプレートファイルを編集して下さい)

’archive.php’(アーカイブ)ファイルの中から次の部分を探して下さい。

	<div id="container">
			<div id="content" role="main">

<?php
	/* Queue the first post, that way we know
	 * what date we're dealing with (if that is the case).
	 *
	 * We reset this later so we can run the loop
	 * properly with a call to rewind_posts().
	 */
	if ( have_posts() )
		the_post();
?>

↓これを、次の様に追加/編集して下さい。

	<div id="container">
			<div id="content" role="main">

<?php
	/* Queue the first post, that way we know
	 * what date we're dealing with (if that is the case).
	 *
	 * We reset this later so we can run the loop
	 * properly with a call to rewind_posts().
	 */
	if ( have_posts() )
		query_posts($query_string.'&posts_per_page=10');
?>

赤色の部分を変更すればOKです。表示件数は、緑色の数字でお好みで設定して下さい。これでアーカイブページの表示件数が変わったハズです。

WordPress 3.xデザイン&カスタマイズスタイルブック 複数ブログ管理からスマートフォンサイトまで、一歩進んだWordPressサイト構築術
WordPress 3.xデザイン&カスタマイズスタイルブック 複数ブログ管理からスマートフォンサイトまで、一歩進んだWordPressサイト構築術

 


にほんブログ村 ブログブログ ブログノウハウへ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です