Display certain header for certain pages

  • arawaf

    #6899

    Hey all,

    First of all, thanks for the great theme.

    My problem is I want to change the site header depending on the page so that each page will come with its own header related to the content of the page, but am having trouble doing so. The idea came up when I noticed that if I set a page’s Slider Image in the Page-Specific Options to Featured Image, the Featured Image would actually replace the header.

    Now I am trying to give each page a Custom URL to display as the header by changing the Page-Specific Slider Image option to Custom URL, but even when I size it properly and make sure the address is correct, it won’t display the Custom URL and only displays the global header.

    I don’t want the Featured Image to become each page’s header, I want it to be a custom URL.

    Global settings has Slider Image set to Featured Image at the moment.

    To see what I mean, you can visit http://www.blue-orleans.com to see the global header.

    Then go to the 1118 Adams page under “Our Experience” (http://www.blue-orleans.com/work/1118-adams/) to see a page where the Featured Image has actually replaced the header. This is what sparked my idea.

    Again, the problem is I want the featured image to be something else (for the sake of the Our Experience parent page thumbnail) and want the page’s header to instead call up a different picture from my server. It may be a simple code fix, but I generally don’t know how to alter more than the CSS of a website (never learned proper coding).

    Thank you,

    Ali

    Admin

    Syahir Hakim

    #36025

    The slider image settings is unrelated to the image being used for the header. You can’t use the slider image’s custom URL setting to affect the header.

    The header image will be replaced with the featured image only if the featured image is equal to or greater than the dimension of the header image, regardless of the slider image settings. At this point, there is no option to define a custom URL for the header image.

    But you may achieve this if you’re using a child theme. Or you can probably find a plugin that’ll allow you to set a different header image without resorting to the featured image.

    arawaf

    #36026

    Okay, thanks!

    I actually am using a Child Theme. Is it easy to do?

    Admin

    Syahir Hakim

    #36027

    Add this to you child theme’s functions.php file:

    <?php  /* Only add this line if you're working on an empty functions.php file */
    /**
    * Manually set different header image for individual pages
    */
    function graphene_custom_header_image( $img_url ){
    /* Replace page-slug with the actual page slug */
    if ( is_page( 'page-slug' ) ) return 'http://www.new-image.url';

    return $img_url;
    }
    add_filter( 'graphene_header_image', 'graphene_custom_header_image' );
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.