Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/lolipop.jp-dp07276078/web/blog/wp/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/lolipop.jp-dp07276078/web/blog/wp/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/lolipop.jp-dp07276078/web/blog/wp/wp-includes/theme.php on line 508
blog.cori95.net : WordPressで1件目の記事と個別ページだけに処理をする

2008/01/03

WordPressで1件目の記事と個別ページだけに処理をする

WordPressでリストページの1件目の記事と個別ページだけに処理をするif文。
例えば、1件目の記事と個別ページだけに広告を表示するならindex.phpに下記を追加すればよいかと。
メモ的に。

<?php global $wp_query;  if (is_single()|| $wp_query->current_post==0) { ?>
…個別ページと1件目だけに表示したいもの…
<?php } ?>

別にis_single$wp_query->current_post==0の0を変更すれば何件目でもよい。
普通にプログラミングできる人には説明はいらないかなぁとか思います。
例えば4件目ならこれ。n件目ならn-1にすればいい。

<?php global $wp_query; if ($wp_query->current_post==3) { ?>
…個別ページと4件目だけに表示したいもの…
<?php } ?>

Posted at 19:50:01|個別ページwordPressトラックバックURL||
はてなブックマークに追加! この記事をLivedoorクリップ! Yahoo!ブックマークに追加! del.icio.usに追加! ニフティクリップに追加! Buzzurlに追加! このページを POOKMARK Airlines の行き先に登録する BlogPeople Instant Bookmark に追加! newsing it!に追加! PingKingポッケに追加!

トラックバックURL

トラックバック URL :

コメント »

この記事にはまだコメントがついていません。

コメントをどうぞ

HTML convert time: 0.093 sec. Powered by WordPress ME