Changing background image for each page
-
Hello guys,
I’m trying to use a method I found for changing attributes in the body through custom fields so that I have a different image for each page.
So I have 2 custom fields, for example:
background-color -> #aa4339
background-image -> /images/ground01.pngand on the page.php below <?php get_header(); ?> I’ve put:
<style type=”text/css”>
body {
background-image: url(<?php bloginfo(‘template_url’); ?><?php echo get_post_meta($post->ID, ‘background-image’, true); ?>;
background-color: <?php echo get_post_meta($post->ID, ‘background-color’, true); ?>;
}
</style>
When I examine the source code it successfully returns:
<style type=”text/css”>
body {
background-image: url(https://localhost/fragmentos/wp-content/themes/fragmentos/images/ground01.png;
background-color: #aa4339;
}
</style>But still both the background image and the color fail to load.
What do you think might be the problem?Thnx!
- The topic ‘Changing background image for each page’ is closed to new replies.