• Hello,

    I was hoping someone could help me figure out how to set a unique header image for each post. I’ve seen some solutions on here to do this for categories, but given that they all seem to use if loops, it would get out of control for a site with hundreds of different pages.

    I was hoping there would be some way to use Custom Fields to accomplish this – where I could set a post to have a custom field named ‘headerImage’ with a value of ‘foo’, and then the page for that could include a class in the header div of equal to ‘foo’, that way I can just set the images in a stylesheet. Or, even more directly, if I could set the value to ‘foo’ and have the page have <div style=”background-image:url(“img/bg/foo.jpg”>

    I really have no idea how to do any of this – I can write in xhtml and css, but haven’t played around with WordPress much, and any handholding would be very appreciated.

    Thanks!

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thanks t31os for all your time and patience in this situation!!,

    If I got it right, according to this code, I will just have to create a folder with the images as: subdomain_name_1.jpg, subdomain_name_2.jpg, etc, set all the paths..and this hack will pick the right picture,according to the element “someid”, it is great!!

    However, I donot know what am doing wrong, but it is not working out…in Artificial Intelligence, however, it does not crashes.
    I have done as you told me, now there is a part I do not understand clearly…about the “someid” and the CSS ID..meaning how do I add “someid” in the CSS?…As #someid { and using the same spec’s as “intro_right” for padding, margins, etc}?
    Or within “intro_right”… {background: url(someid)}?…or add it like a path…’background: url(wp-contents/imagesfolder/someid.jpg)’
    Sorry, I am lost here, I will do some more attempts…
    Thanks again!!

    Anyways,

    I went by the way I mentioned before, by creating “clones” themes based on Artificial Intelligence, by changing the CSS Header name, and reloading the right pictures for each.
    It is a longer way, but I have more control over the <p>text</p> in some templates that I also wanted to change for every sub-domain.
    However, t31os, thanks a million for your time and patience, I try your way, but am sure I did something wrong.

    Basically what we’re doing is inserting

    #someid {}

    Into the header section when a sub-domain exists…

    It could be renamed to..

    #myid {}

    #thisid {}

    #header {}

    whatever you want, it was purely an example…

    I then reused the domain and sub-domain to build part of the image URL, again this was purely for the example and doesn’t have to work that way…

    I tested the code locally and it does function…

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Unique Header Image for Each Post’ is closed to new replies.