Jump to content

Alter existing PHP code to stop over riding backgrounds


fartnuts

Recommended Posts

Hey guys!

 

This is driving me insane and I've done this dozens of times before and I know it's simple, but I can't seem to figure it out :(

 

I have the following piece of code in my WordPress theme set right now that when I add a custom background image to a post, it overrides the set custom image for the home page and rest of the site.

 

I need to fix it so that when I can set a background custom image for each post and it doesn't override any other set custom backgrounds.

 

Here's the code:

 

/* Add a custom bg if it exists */

<?php $homepage_bg = get_option_tree("default_bg");

if(get_custom_field('custom_background_image')) { ?>
    body {background: url('<?php echo get_custom_field('custom_background_image',true); ?>') top left fixed repeat;}
<?php } elseif (isset($homepage_bg[0])) { ?>
        body {background: url('<?php echo get_option_tree("default_bg"); ?>') top left fixed repeat;}
<?php } else {} ?>

<?php global $theme_options; ?>

 

Any thoughts?

 

Thanks to everyone in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.