inserting_slider.html

Inserting the slider with shortcode

You can place your sliders into pages and posts with their shortcodes. You can find the shortcode for each slider in this page next to their names in the list view. To insert the slider, edit a page or post and insert its shortcode into the WordPress text editor.

Inserting the slider with the LayerSlider WP widget

LayerSlider WP supports widgets, so you can place your slider in your front-end page just by a drag n’ drop. To do that, navigate to the Appearance menu on your left sidebar and select “Widgets”. Grab the LayerSlider WP Widget and drop it into one of your widget area.

Please note that some themes may not support a widget area what you need. In this case, you can create a new widget area by editing your theme files. Here is the official documentation about widgetizing your theme.

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] )

The $sliderID parameter can be found on the plugin page in the slider list view at the first table column.

The $pages parameter is a comma separated list of pages either by name or the ID of the pages. If you are unsure about your page names or IDs, look at their URL, it is the last component.

There is a special page name, the “homepage”, with you can filter LayerSlider WP to display the slider on your home page. It is also works if you set up a static custom page instead of the default post listing.

The follwing examples are all valid, you can use either of these, you can even mix them on your own needs:

<?php layerslider(1); ?> // Displays the first slider on every page
<?php layerslider(1, 'homepage'); ?> // Displays the first slider only on your home page
<?php layerslider(1, 'my-custom-post-title'); ?> // Displays the first slider on a custom page by name
<?php layerslider(2, '1369'); ?> // Diplays the second slider on a custom page by ID
<?php layerslider(3, 'homepage,about-us,1234'); ?> // Displays the third slider on multiple pages

It is important when you want to insert a slider to check its ID on the LayerSlider WP slider list page. When you removes some sliders, their IDs won’t be reindexed and the sequence may broke up. This is important to keep persistent your sliders preventing unwanted changes on the already inserted ones.