开发者

Customizable background image on WP theme

开发者 https://www.devze.com 2023-01-08 00:29 出处:网络
I have created a wordpress theme and I made it so the background image can eas开发者_如何学Pythonily be changed. The only problem is that currently I have to make the change manually (ie FTP) and Id l

I have created a wordpress theme and I made it so the background image can eas开发者_如何学Pythonily be changed. The only problem is that currently I have to make the change manually (ie FTP) and Id like to provide my client with a Template options page with an "Upload new background image" option in it.

Im pretty sure this is possible, I just dont know where to start.

Could someone point me out in the right direction?


This will do it for you. Just add the following to your theme's functions.php file:

add_action( 'after_setup_theme', 'add_custom_background' );

This only works in WordPress 3.0 as of now. Of course, you should be running the latest version anyway. It will add a custom background menu in the admin area (under 'Appearance') and will add the styles to the body tag. Also handles uploading, centering/tiling (x, y, or both) images/background colors. Very simple and great functionality.

0

精彩评论

暂无评论...
验证码 换一张
取 消