如何加一个随机图片
I’ve added a simple hack to the default Kubrick theme which displays a random header graphic. Here’s how it works. I added the following function to the top of header.php:
NOTE: this must come AFTER the doctype & html lines.
<?php
function header_graphic() {
echo "/images/";
$num=rand(0,8);
echo "kubrickheader".$num.".jpg";
};
?>
Next, I changed the style element for header as follows:
#header { background: url("< ?php bloginfo(’stylesheet_directory’); header_graphic(); ?>“) no-repeat bottom center; }
Finally, I saved several header graphics in my image directory named kubrickheader0.jpg through kubrickheader7.jpg.
If you’d like to see the different graphics, here they are:
kubrickheader0.jpg
kubrickheader1.jpg
kubrickheader2.jpg
kubrickheader3.jpg
kubrickheader4.jpg
kubrickheader5.jpg
kubrickheader6.jpg
kubrickheader7.jpg
kubrickheader8.jpg
kubrickheader9.jpg
绿色为可改区,根据情况自己改
相关文章:- BlueHost Upgrades Their Hosting Plan
- wordpress随机显示的图片的又一种方式
- Graflex Graphic 我现在用的大幅机
- Ensign Autorange 820
- rodenstock制版放大镜头
- Netfirms web hosting product line Mega-upgrades!
- 摄影维基中文的FOTOWIKI.CN
- Flüssige Fotoemulsion
- 新式穿墙软件torpark和tor+privoxy
- Google 新服务 Click-to-Call
中文关键字:随机 图片 kubrickheader header the gra rsquo directory function hic added echo here hics to













