I am trying to get a carousel slider from the Revolution Slider Addon into the header on the homepage only. And I want it under the header bar (where the menu is). However, the template I'm using doesn't inherently support the slider. So I decided to go into the header.php and input the code myself to put the slider over the top of the default header image. However, when I do this, it also puts the slider in the header on the blogs post page. It doesn't appear anywhere else on the site besides the home (desired) and the blogs post page (undesired).

Is there a way to restrict this code to ONLY the website homepage and not appearing in the header anywhere else? Maybe some kind of if-conditional?

Here is the code section where I put the slider in header.php:

<!-- Mobile Menu -->
    <div class="header-fix-wrapper">
        <header class="clearfix<?php if($sonus_opt['podcast-mode'] == 1){ if(!is_home()){ if(is_single()){ if($this_is_podcast == 1){echo " single-header";} }elseif(is_front_page()){echo " home-header"; }}} ?>">
            <div class="header-bar">
            <!-- Head Bar -->
            <?php add_revslider('funky-slider','homepage'); ?>

you can conditionally display it only in front page by is_front_page()

reference: https://developer.wordpress.org/reference/functions/is_front_page/


if (is_front_page()) {
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.