• Resolved Uwhoosh

    (@uwhoosh)


    Hello, designed a new site and as usual celestial lite is my theme of choice. Have a bit of customization issue that finding hard to resolve. I’d like to have the header image in some pages the blog roll, but not the blog posts. Also I plan to create a separate header image for each of the pages.

    How I normally do this is create a separate header.php for each page and hardcode the image url into the header.php. Then create a template for each page and call the respective header.
    But I already have 4 static pages and the blog roll on the show site and need to find a more efficient way to do this.

    I don’t mind messing around with code, just need someone to point me in the right direction and I’ll probably figure this out. I’d prefer a CSS option but I’m equality comfortable writing php code.

    Thank you all.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Uwhoosh,

    You could still create different headers, call the default header in index.php (the blogroll), dont’ call get_header() from single.php for the blog post’s page, and finally on page.php you could set up a series of conditional statements, something like

    if(is_page( 'about' ) ) {
      get_header('about');
    } elseif (is_page( 'contact' ) ) {
       get_header('contact');
    }

    Make sure you have header-about.php and header-contact.php and you should be good to go. Obviously, I use about and contact as example, but the same applies to other pages you might have created in your child theme.

    Although this solution doesn’t spare you from creating different headers, you won’t need to create a page template for each different header.

    I hope this helps ??
    – Maria Antonietta.

    Thread Starter Uwhoosh

    (@uwhoosh)

    Thanks Maria.
    If conditional statements, that could be what I need to use. Let me do come php coding and see if this works.

    I’d still have to create a lot of headers…and there are elements in the header.php (for instance the menu, logo) that I want to call in single.php. But I can hide the image using display:none; so that shouldn’t be a major stumbling block…

    Yes, you could hide elements using CSS in some cases or you could use conditional statements inside the header code related to specific header elements. It all depends on how complex your design is, and it looks like it’s fairly complex.

    Let’s see what works best, keep us posted!

    This is where you should use widgets to load your header images and not the WP Header option. The idea is to use widgets for your images (or image widget plugins), and then use a plugin like Display Widgets to choose what pages you want each one to show on. Display Widgets lets you easily do this. No coding is needed, except if you use a text widget to load an image, but even that is simply done with:

    <img src="image url here" alt="short description"/>

    Publish one in the Showcase Header position, so you get the curved graphic on your front page, then use the Banner position for the rest of the pages in your site.

    As a side note, if using a text widget for header images, use another plugin called “Remove Widget Title” to have the title in the admin side (so you know what it is) but not seen in the front-end.

    I note that you still recommend Advanced Text Widget on your instruction page. Are you no longer recommending it? I’ve had issues with it today not showing up a banner on a new page so wonder if there’s a compatibility issue? Any suggestions. I’m loathe to install new widgets and then having to redo each banner for every page.

    As an aside, all existing pages using the Advanced Text Widget work fine. Code placed in the latest page was the same (with exception of the image name) so am wondering if it’s to do with the WP update.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Header Image’ is closed to new replies.