WordPress 3.0 では、投稿時にアイキャッチ画像を指定することで、投稿ページ毎に違うヘッダーを表示させることができる「カスタムヘッダー機能」が装備されたが、あいにく 3.0 以前のヴァージョンにはその機能がない。
そこで、ヘッダー画像をランダムに表示させたい場合には、「 Random Image Rotation 」を使用する。
導入方法は、
1.ダウンロードサイト下部に 「 PHP sourse right here 」 というリンクがあるので、そこをクリック。テキストファイルが開かれるので、右クリックして「名前を付けてページを保存」する。
2.ダウンロードしたテキストファイル 「 rotate.txt 」 の拡張子を 「 php 」 に変更する。
「 rotate.txt 」 → 「 rotate.php 」
3.テーマの 「 images 」 フォルダの中に、「 ramdom 」という名のフォルダを作成し、ここに「 rotate.php 」 とランダム表示させたいヘッダー画像複数枚を入れる。
4.この「 random 」 フォルダを 「 /wp-content/themes/テーマ/images/」 ディレクトリに、フォルダごとアップロードする。
5.「 style.css 」 でヘッダー画像を指定している 「 background 」要素の 「 URL 」 を、「 ratate.php 」 へのパスに変更する。
background: url(images/random/rotate.php) no-repeat;
これで作業は完了!ヘッダー画像がランダムに表示されるようになる。
6.尚、ヘッダー画像を入れるフォルダを変更したい場合は、「 rotate.php 」 の107行目 「 $folder = ‘.'; 」 の箇所を変更する。
$folder = ‘/www/example.com/images/画像を入れるフォルダ名/'; ← 画像を入れるフォルダのサーバのフルパス
上記の画像を入れるフォルダまでのフルパスは、それぞれの環境に応じて適宜変更して記述してください。
※「 Random Image Rotation 」 はイメージ画像をランダムに表示するコードなので、ヘッダーに限らず、サイドバーなどでも使用することができます。
Hey I am so happy I found your weblog, I really found you by
mistake, while I was browsing on Google for something else,
Anyhow I am here now and would just like to say thank you for
a remarkable post and a all round thrilling blog (I also love the theme/design), I
don’t have time to look over it all at the minute but I have bookmarked
it and also included your RSS feeds, so when I have
time I will be back to read a great deal more, Please do keep up the great work.
Visit my web-site – fifa 14 free coins