简体   繁体   中英

Customizable background image on WP theme

I have created a wordpress theme and I made it so the background image can easily 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM