• Hi,
    I am tweaking the theme JQ quite a bit for a website with mainly “static” pages. It is working fairly well but I have a question concerning background images:

    I need to have separate background images for several sections of the site. I will be using templates to customize the sections since there are a lot of other differences too. If I could call a specific background image in these templates by making a condition saying something like:

    if (h2.page_headline == “thisTitle”) {
    background-img = “thisPage’s-background-image.jpg”;
    };
    (I would know how to write this in Flash but not in PHP..)

    If that is possible I could actually use only one template for most of these pages. If not, I have to make a custom template for each of the individual sections/submenu-pages which will make it much more difficult to update for the customer.

    Because of several reasons the background images actually reside in a separate div in the pages. Which means I can’t put them in the CSS-file.

    Is there anyone that can help out there? ??

Viewing 8 replies - 16 through 23 (of 23 total)
  • No problem, body classes are such a handy trick.

    Sorry I am new to wordpress. I am trying to get a background on a specific page and i understand that I can use a body tag, but can someone break it down for me. I tried doing the above and it isn’t working for me. I am sure I am doing something stupid. Many thanks.

    Does your theme have the body_class function? Could you post a link to the page you are having problems with?

    Thanks for responding JLeuze!

    I am totally lost has to how to do this with the template that I have.

    I want to have a video page with a different background for just that page.

    That page is at https://eve-online-dark-taboo.com/blog7/?page_id=4

    Any help would be appreciated. I have gone here:

    https://codex.www.ads-software.com/Function_Reference/body_class

    But i can’t make heads or tails as to if my theme will access the post-template.php

    Many Thanks!

    The link you posted is broken for me, but it looks like you are using the Arras theme which has the body_class function, or something similar.

    Take a look at the body tag on this page:

    <body class="page page-id-2 page-template page-template-default">

    So adding this to your stylesheet would change the background of just that page to black:

    body.page-id-2 {
    background:#000000;
    }

    Dear JLeuze,

    I got it to work! I got it to work for a catagory.

    But, I can’t seem to get it to work for a tag. i look at a post for a tag and the body class doesn’t spit out the tag info?

    Ideas?

    Many Thanks!

    For some reason, Arras has its own custom body class function:

    <body <?php arras_body_class() ?>>

    Doesn’t look like it supports tags, but the standard WordPress body class function does.

    Can anyone explain what is the difference between a body class of “single” or “singular”? I’ve looked at the Thematic dynamic-classes.php and it provides the exact same comment about those two classes, and I cannot figure out how a particular “page” gets a class singular vs or in addition to a class single. Can anyone explain?

    And how would I go about turning off some of the humongous number of dynamic body classes generated by Thematic? (I understand the general principle of filters, but I need to know specifics: what php file to put what code into to turn off body classes I don’t want)

    TIA

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Adding custom background image to page-template(s) through php?’ is closed to new replies.