Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning different banner pics to each page in Wordpress

    I have a Wordpress theme I'm modifying (Bouqet, in case you're interested), and I want to get it to show a different banner pic for the different pages. The theme seems to have two stylesheets, one editable in Wordpress theme editor, and a second that is specific to the color scheme I am using. Originally, the header code shown below did NOT have the "style" attribute with a background image. The image is supposed to be defined in the CSS sheet specific to the color scheme. I have modified the html to include an inline style attribute that I want to override the background image defined in the stylesheet. I am trying to use the post ID to determine what page the user is on, and I have named my banner files the number of the post ID. Here is the code in the header.php file that I'm working with:

    [CODE]
    <header id="branding" role="banner" class="clearfix" style="background-image: url(<?php echo $post->ID; ?>.png);">
    ...more code here...
    </header>
    [CODE]

    The problem that I'm running into is that this only seems to work for one page (it happens to be my main page). All other pages show a blank banner as if it can't find the image. Am I mistaken in my coding or my approach?

    Thanks,
    Jeremy

  • #2
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    Was just doing a little more testing, and realized that maybe the problem is that I am not properly specifying where the files are located. The inline style just has an image url of postID.png, which would suggest it finds the file in whatever folder the page is currently being loaded from. Now I am trying to code the inline style to spell out the path, but I can't seem to find the right syntax. I've tried:

    [CODE]
    <header id="branding" role="banner" class="clearfix" style="background-image: url(c:/wamp/www/nhpn/<?php echo $post->ID; ?>.png);">
    [CODE]

    and this:

    [CODE]
    <header id="branding" role="banner" class="clearfix" style="background-image: url(/nhpn/<?php echo $post->ID; ?>.png);">
    [CODE]

    and this:

    [CODE]
    <header id="branding" role="banner" class="clearfix" style="background-image: url(localhost/nhpn/<?php echo $post->ID; ?>.png);">

    As you can see, i'm workiing with a local WAMP server right now, but I'll be doing it again on a hosted site. The main page loads at localhost/nhpn.

    Am I on the wrong track? I've spent upwards of 3 hours on this now, and it's reallly getting annoying!

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is no one able to answer this?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •