Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #115372
    nimadude
    Participant

    Hi there,

    On my website (http://khosa.emergencyradiology.ca/) I am trying to only show the header image on the front page and not elsewhere. But when I hide using CSS it also hides the menu with it, but I would like to keep the menu everywhere.

    Thanks

    #115375
    Mahesh
    Keymaster

    @nimadude: Go to Dashboard=> Appearance=> Customize=> Additional CSS box and add the following CSS:

    body:not(.home) .site-branding {
        display: none;
    }

    Regards,
    Mahesh

    #115391
    nimadude
    Participant

    perfect thanks!

    #115419
    Mahesh
    Keymaster

    @nimadude: Thank you for your appreciation. If you like my support and Studio theme then please support by providing your valuable review and rating at https://wordpress.org/support/view/theme-reviews/studio?rate=5#postform
    Have a nice day!

    Regards,
    Mahesh

    #115477
    nimadude
    Participant

    Hi Mahesh,

    Will do, but first, 2 problems have occurred. With the css hiding, I think all the pages still load the image into the header then hide it (which slows things down and the image flashes briefly before being hidden, on pages it isn’t supposed to be there). Is there a way to hide the header image in the theme code itself, without css?

    Also, with this technique, I cannot put featured images for other pages. I want to only have header image on homepage but featured on others.

    Thank you!

    #115488
    Mahesh
    Keymaster

    @nimadude: For this, you’ll need to customize the theme further. However, this feature is already built-in in Pro version. I recommend you to upgrade to Pro version.

    Regards,
    Mahesh

    #115496
    nimadude
    Participant

    I understand. Unfortunately I’m working on this for a friend and they were hoping to get it done free. If you could please direct me to where in the code I can hide just the header image but keep featured images that would be greatly appreciated!

    #115502
    Mahesh
    Keymaster

    @nimadude: Create a child theme, you can find more details on creating child theme HERE. Then in your child theme’s functions.php, add the following codes:

    function studio_child_header_on_homepage() {
        global $wp_query;
    
        $page_for_posts = get_option('page_for_posts');
    
        $page_id = $wp_query->get_queried_object_id();
    	
        if ( !is_front_page() || ( !is_home() && $page_for_posts == $page_id ) ) {
            remove_action( 'studio_header', 'studio_site_branding_start', 30 );
            remove_action( 'studio_header', 'studio_logo', 50 );
            remove_action( 'studio_header', 'studio_site_title_description', 60 );
            remove_action( 'studio_header', 'studio_site_branding_end', 70 );
        }
    }
    add_action( 'studio_header', 'studio_child_header_on_homepage', 15 );

    Note: Displaying featured image on other pages as header image, free this doesn’t have this feature.

    Regards,
    Mahesh

    #116191
    nimadude
    Participant

    Thanks Mahesh. Unfortunately that last code removed the header from all pages, including home.. 🙁

    #116222
    Mahesh
    Keymaster

    @nimadude: I’ve changed the conditions in the above, it will work now on static pages as well. Please check. Let me know if any problem.

    Regards,
    Mahesh

    #116224
    nimadude
    Participant

    Thanks!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Showing Header Image Only on Front Page’ is closed to new replies.