• Resolved paulpi

    (@paulpi)


    I’m using the Astra theme. And when I use hooks to insert a shortcode, the slider is shown on all pages.
    How to make the slider only on the front page(home page)?

    Using the page “your latest posts”.

    • This topic was modified 4 years ago by paulpi.
    • This topic was modified 4 years ago by paulpi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Laszlo

    (@laszloszalvak)

    Hi @paulpi

    I assume the action where you hooked the function that renders your slider gets fired on all pages, and that’s why your slider is rendered on all pages.

    If you want to display the slider only one the home page, then you should rather hook your function to an action that gets fired on the home page only.

    In that case if your theme doesn’t have such unique action for the homepage only, then the other options you have are either:
    A.) publishing the slider with shortcode ( within the do_shortcode() function of WordPress ) and you could use the shortcode with the “page” parameter and “home” value, like you see in this example:
    https://smartslider.helpscoutdocs.com/article/1720-publishing-on-wordpress#home_page

    B.) You could wrap your code with an IF condition, to run the shortcode only on the blog home page or on the front page ( depending on what you would like to do exactly ). WordPress has a dedicated function for this:

    Best regards,
    Laszlo.

    Thread Starter paulpi

    (@paulpi)

    Thanks a lot, it was so easy! I will read more instructions in the future.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Front page’ is closed to new replies.