• I am setting up biography pages on my website for each exhibitor of the event I am involved with.

    Here is an exhibitors page: https://www.circus11.com/wordpress/?page_id=146

    On the main website sections ‘HOME, LINE-UP, ABOUT’ etc I want the alternating header images to stay, but on each exhibitors page I want to be able to select a certain header image to display the exhibitor’s work.

    Does anyone know how I can do this? I think I may have to edit or input some code into the function.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 15 replies - 1 through 15 (of 52 total)
  • Marventus

    (@marventus)

    Hi,

    Take a look at Conditional Tags. Basically, you need something like this:

    <?php
    if (is_home() || is_page('bla') || is_page('bla') {
    Alternating images
    }
    elseif is_page('bla') || is_page('bla') etc. {
    Static images
    }

    Where bla is the ID number of the targeted page, and || stands for OR.

    Thread Starter ieatwork

    (@ieatwork)

    Thanks Marventus,

    Where would I need to insert this code? Into the header.php?

    Marventus

    (@marventus)

    Yes, header,php. Sorry I forgot to specify that.

    Thread Starter ieatwork

    (@ieatwork)

    Sorry to keep bugging you, but could you have a look at my header.php code and indicate where I should insert the code?

    I am on a deadline to finish this site and this is the only issue which is holding me back from getting it online! ??

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Marventus

    (@marventus)

    Sure, I can take a look, but you should use Pastebin in the future for pasting more than 10 lines of code, as per the forum guidelines.
    So please do that and share your pastebin link.
    Thanks!

    Edit: Oh, also, one question: do you want static images on Exhibitor pages only?

    Thread Starter ieatwork

    (@ieatwork)

    Here is my Pastebin link as requested: https://pastebin.com/DZ7RTFbj

    Hope it works and thanks so much for taking the time to help me!

    Marventus

    (@marventus)

    Did you see my question on the Edit above?

    Thread Starter ieatwork

    (@ieatwork)

    Yes just static images on Exhibitor pages.

    In fact the only pages which require the random image rotation is About and Contact.

    Thread Starter ieatwork

    (@ieatwork)

    Did the Pastebin link work ok for you?

    Marventus

    (@marventus)

    Ok, I took a look at your header. Based on what I’ve seen, the header checks whether the page has a featured image associated to it, and if no image is found, it displays the header images.
    What happens if you add a featured image to the pages in which you want static images?

    Thread Starter ieatwork

    (@ieatwork)

    I have just added a featured image to an Exhibitor page and this is how it displays: https://www.circus11.com/wordpress/?page_id=126

    For some reason it has duplicated the image, with the top one replacing the header image with my logo on.

    Hmmm…

    Marventus

    (@marventus)

    Oh, a couple of things on the side:
    1. Static urls:
    I noticed you used several static URLs in your header.php. It is always preferable to use dynamic ones, so when you move your site from a local or test environment to a live one, things don’t break. You should replace all your:

    https://circus11.com/wordpress

    with

    <?php bloginfo( 'siteurl' );?>

    2. Current menu items:
    Your current styles for menu items with child items are working a little off. For instance, when you click on the “Exhibitors” page, all your sub-items are displaying a current or hover state.

    Thread Starter ieatwork

    (@ieatwork)

    I think this might have something to do with me duplicating the ‘branding’ div in the header.php

    You’ll see I called the duplicate ‘branding2’.

    The header image with the logo on just needs to be static and remain in the same place on each page. Is there some simple code I can insert to achieve this rather than duplicating the branding div?

    Thread Starter ieatwork

    (@ieatwork)

    Thanks for the tip regarding static URLs. Will I need to change these in just the header.php or do I need to do it for every php file with URLs in?

    Marventus

    (@marventus)

    I just saw your last post.
    That happened because you are using the exact same code for your logo and for your page images.
    Since your logo is static, you don’t really need the default code inside your branding div.
    Replace the entire contents of that div with:

    <img src="<?php bloginfo( 'siteurl' ); ?>/wp-content/uploads/2011/10/logo.gif" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

    The final result should be:

    <div id="branding">
    <img src= etc...>
    </div><!-- #branding -->

    You should change all your static URLs in all php template files that contain them. You won’t be able to add them in non-php files, such as .css files, etc.

Viewing 15 replies - 1 through 15 (of 52 total)
  • The topic ‘Need to make random header image static on certain pages. Help!’ is closed to new replies.