admin管理员组

文章数量:1334328

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>
    <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'); ?>
            </div>
        </header>
    </div>
</div>

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>
    <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'); ?>
            </div>
        </header>
    </div>
</div>
Share Improve this question asked Jun 7, 2020 at 23:21 KadeKade 1
Add a comment  | 

1 Answer 1

Reset to default 0

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

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

Try:

if (is_front_page()) {
    add_revslider('funky-slider','homepage');
};

本文标签: How do I get the Revolution Slider in the header on the homepagebut not the blog index page