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!

I am not sure I understand what you are trying to accomplish. If you are trying to set a different custom background image per post, then you might need to include code that pulls in the post id.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.