Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • #23960


    I’ve an error when inserting php function for layerslider in my php theme files : “Fatal error: Call to undefined function layerslider() in …”

    I inserted it like <?php layerslider(1, ‘homepage’); ?>, the good way I think.

    Thanks for helping me.


    Nobody use php function for displaying slider in homepage ?


    I’ve found the BUG !

    Happened when :

    – creating a new page ; no content inside

    – set this page as “A static page” in the Front page displays in “Settings > Reading”

    Because there has never been a slider shortcode inside the page content, “ShortcodeHelper::$tree” is empty and not an array. So the function “post_has_layerslider” return always “false”.

    How do I solve this temporarily ?

    I inserted a layer shortcode inside page, I updated, and I deleted it just after. It seems that Avia keep in memory “av_layerslider” also when there is no more slider in page content.


    If you want to use php to call the slideshow (which imo doesn’t make much sense) you can try the do_shortcode function:

    echo do_shortcode('[av_layerslider id="3"]');

    Instead of 3 insert the id of your LayerSlider.


    Why it doesn’t make sense ?

    You have created php function to display the slider in php files, so I use it !

    PHP function “layerslider(xxx)” does the same as “do_shortcode(…)”, I want to use the best way to display my slider on homepage.

    How do you manage this with the slider in demo ?


    We just use the advanced layout builder on the demo website. You can use the code from here: https://gist.github.com/InoPlugs/5d0d1477a0252aca1081 to reproduce the front page layout – just insert it into the “standard editor” and save the page. Then switch to the “advanced editor” to edit the elements.


    No I don’t want to use this method, I want to use the method you’ve planned for theme’s php files (I’m a developper so inserting a lot of shortcodes inside editor is not the best way for me)


    Hi JudeAAZ,

    I have no idea where you got the idea that the theme somehow wants you to write php to make layouts. The theme demo uses only the tools within the wordpress admin area.

    There is no custom php for any slideshow on the demo. It is entirely created using the Advanced Layout Editor.




    This is in your docs :

    Calling the slider from your theme files

    Because a slider can be an integral part of your site, you may want to place it into your theme files. There is a PHP function with filtering options which you can call for example from the header.php file of your theme and it inserts your slider into your home page or certail other pages depending on your filtering settings. Here is the function definition:

    layerslider ( mixed $sliderID [, string $pages] )


    I prefer this way of doing than inserting shortcodes in editor. If you provide this function, I expect it to work !


    We modified the layerslider shortcode and the default function layerslider() will not work. Also the docs are not written by us but they just come with LayerSlider plugin which is bundled with our theme and they do not reflect all supported features. As you pointed out above the

    echo do_shortcode('[av_layerslider id="3"]');

    does the same as layerslider(xxx) and it works out of the box. Please use this function. It’s actually even more efficient than the layerslider() function because you skip some “safety checks” (like if the shortcode syntax is valid, etc.).


    Thanks for this explanation

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Layerslider in php file’ is closed to new replies.