资源描述:
《如何给press主题添加自定义头部图像》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、WordPress 3.0给我们带来了以往版本所没有的一些明显的新特性,其中一个显著的亮点就是让我们可以在后台控制面板中设定主题的头部图像,这个功能同时也被整合到了其默认主题TwentyTen中。到了WordPress3.2,在新的默认主题TwentyEleven中,我们还可以设定随机显示头部图像。这篇文章将要讲述的是,如果你使用的并不是WordPress的默认主题,你的主题又不支持自定义头部图像(CustomHeader),但你又很需要这个功能,那怎么办呢?下文所介绍的方法可以帮你轻松实现你的这个愿望。 添加代码到Functions.php文件你的主题中
2、应该有一个功能函数文件functions.php,如果没有则自建一个,然后复制并粘贴以下代码进去:1.
3、ER_IMAGE','%s/header/default.jpg');8. 9. //Definethewidthandheightofourheaderimage10. define('HEADER_IMAGE_WIDTH',apply_filters('customisetheme_header_image_width',960));11. define('HEADER_IMAGE_HEIGHT',apply_filters('customisetheme_header_image_height',220));12. 13. //
4、Turnofftextinsidetheheaderimage14. define('NO_HEADER_TEXT',true);15. 16. //Don'tforgetthis,itaddsthefunctionalitytotheadminmenu17. add_custom_image_header('','customisetheme_admin_header_style');18. 19. //Setsomecustomheaderimages,addasmanyasyoulike20. //%sisaplaceho
5、lderforyourthemedirectory21. $customHeaders=array(22. //Image123. 'perfectbeach'=>array(24. 'url'=>'%s/header/default.jpg',25. 'thumbnail_url'=>'%s/header/thumbnails/pb-thumbnail.jpg',26. 'description'=>__('PerfectBeach','customisetheme')1.
6、 ),2. //Image23. 'tiger'=>array(4. 'url'=>'%s/header/tiger.jpg',5. 'thumbnail_url'=>'%s/header/thumbnails/tiger-thumbnail.jpg',6. 'description'=>__('Tiger','customisetheme')7. ),8. //Image39. 'lunar'=>array(10. 'url'=>'%
7、s/header/lunar.jpg',11. 'thumbnail_url'=>'%s/header/thumbnails/lunar-thumbnail.jpg',12. 'description'=>__('Lunar','customisetheme')13. )14. );15. //RegistertheimageswithWordPress16. register_default_headers($customHeaders);17. }18.endif;19. 20.if(!funct
8、ion_exists('customisetheme