Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to get different bg image on group of pages

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29738
    jlknauff
    Member

    I have a site that needs three different background images at the moment.

    The most common one is just set by default via CSS.

    The second one, for the home page, is set using the body class, as such:

    Code:
    body.home .topdiv{
    background:url(images/topbg_h.jpg) no-repeat top center;
    }

    The one I’m having a problem with is defining a particular background for for landing pages. It will be the same image, and there will be many landing pages, so I don’t want to manually add a CSS class for each page.

    Is there an easy, scalable way to do this?

    #80962
    doobie
    Member

    You can add this:

    Code:
    <?php body_class(); ?>

    to your <body> tag in your header.php file. This will auto-generate a bunch of classes for you on the body tag. I assume your landing pages will all be in the same category? Or, if they are pages instead of posts, they’ll all use the same page template. If they use the same page template, this function will add a class specifically for that.

    Good luck!

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.