Ad

How To Show Smart Slider Only On Home Page Of Wordpress Blog

- 1 answer

I am using Astra theme and Smart Slider 3 plugin in WordPress. I used Astra Hooks plugin to show slider on header and it worked but the slider is displayed on all pages.

How do I make slider appear on home page header only?

Ad

Answer

wordpress have conditional tags to deal with these problems. i have not used astra hooks plugin, instead you can use the snippet below and paste it in your functions.php file of your child theme. replace your slider's shortcode with [shortcode_of_your_slider] and you're good to go.

if you want to change the position of slider checkout astra visual hooks . right now im using the astra_header_before you cant change it with what ever you want

add_action( 'astra_header_before', 'shalior_display_header_on_front_age' );
function shalior_display_header_on_front_age() {
    if(is_front_page()){
      echo do_shortcode('[shortcode_of_your_slider]');
    }
}
Ad
source: stackoverflow.com
Ad