• Hi!
    I’d like alternate header and background images to show up for posts of a certain Category (“blog”), instead of the main ones set in the theme.
    I want those posts to look like they belong to a different section, still inside my fan site, without having to install a Multisite just for this; I think a different header and bg will do enough.

    I tried to follow some quite old guides to do this, some suggested to make a Custom Category Template, some others to put a condition before the “get_header()” function, but I couldn’t get anywhere near the solution, nor figure out yet what would be the best suited/easiest one in my case…

    Help please!

Viewing 1 replies (of 1 total)
  • Chad

    (@lynneandchad)

    I’d say add the conditional statement. A custom template would make sense if you were changing more.

    Give this a shot in header.php, right where the <header> tag opens:

    <?php
      if (is_category('blog') || is_single() && in_category('blog')) {
        echo '<header id="header" class="col-full blog-header">';
      } else {
        echo '<header id="header" class="col-full">';
      }
    ?>

    That will check to see if you’re on the archive page for the Blog category, or looking at a single post for the Blog category. If so, an additional CSS class is added that you can then use to apply a different background image.

    I haven’t tested it yet, but it should do the trick!

Viewing 1 replies (of 1 total)
  • The topic ‘Change Header/BG images for posts of a specific Category’ is closed to new replies.