This technique allows your WordPress content editors to specify their own custom background image for each page individually using custom fields (or meta boxes).
Insert the following code into the head of your page:
<?php // Make a global query item global $wp_query; if ( get_post_meta( $wp_query->post->ID, 'bkgcustomimage_value', true) ) { $bkgcustomimage = get_post_meta( $wp_query->post->ID, 'bkgcustomimage_value', true ); ?> <!-- A custom background image has been specified. Insert the following styles --> <style type="text/css"> body { background-image: url('<?php echo $bkgcustomimage ?>'); } </style> <?php } else { ?> <!-- No background image has been defined. --> <?php }?>
You will need to suppliment this with additional css which won’t need to change and can therefore be included in the css file.
Revisions
There are no revisions for this post.
No comments yet.