Publishing on WordPress

Shortcode

You can copy/paste the shortcode of your slider into your pages and posts from the Slider settings → General tab.

Gutenberg

Adding a new block

You can publish the slider by creating a Smart Slider 3 block.

Classic Editor

If you are using the Classic Editor, you can use the Smart Slider button to publish your slider, where you can select your slider, and it will paste the shortcode there by itself.

Page Builders

Page builders aren't capable of calling in files, only to display the HTML code of your content, but our slider needs CSS and JavaScript files to be able to work, so what we do is, that in frontend editor page builders we are only showing the shortcode of our slider, but on the actual, live site we are displaying our sliders. So our plugin works with most page builders, but you will only see the result on your published pages.

There are some page builders which we natively support (e.g. via a widget or module):

Of course you can use Smart Slider 3 with other page builders. Probably you'll need to use a shortcode/text module, where you can place the slider's shortcode.

Widget

You can also select our slider in the WordPress' Appearance → Widgets. If you don't have a good widget position, check out the PHP code publishing or this documentation.

Widgets are usually showing up on more pages, so in case you would only want your slider to show up on certain pages, use a plugin, which allows you to select where widgets should show up, like this one.

Possible issue

The slider's shortcode is in a text widget, but it doesn't change in the frontend, only the shortcode text can be seen.

Solution

WordPress doesn't support shortcodes in the text widgets, they only appear, if your theme was coded to show them. You can try to give this option to your theme by putting this code into your theme's functions.php file:

add_filter( 'widget_text', 'do_shortcode' );

But we have our own widget, and you should use that instead.

⚠️ Warning: If you make a mistake in the functions.php file, both your backend and frontend will be blank, so have a backup, and use ftp!

PHP code

For this publishing method you will need PHP and HTML knowledge. You can copy the PHP code of your slider from the Slider settings → General tab.

⚠️ Warning: If you are not sure about yourself, always have a backup, and edit from your FTP, not from the Appearance → Edit, because you can make php errors there, big enough to make your whole website blank including your back-end.

WordPress offers a do_shortcode function, what you can use to put shortcodes into your theme's php files.

  • You will need to find the codepart, where you want to have your slider. You can find a documentation on how to do that here. Also this video could help.
  • After you have got the code, use the do_shortcode function to put your slider there. You can also use some other WordPress functions to make your slider only show up on certain pages.

How can I publish the slider, where I want it to be?

Usually WordPress themes aren't giving a good widget position to put something right under your menu, or in other places where a slider would be nice, so the way you can do that is you could use our php code publishing.

To figure out which codepart you would need, use your browser's developer tools.

The part where people mostly want to have their sliders is right under the </header> code. That is usually in the header.php file, but it could be in other files too. You can search for a codepart in multiple files, as you see here.

⚠️ Warning: If you modify your theme and then update it later, all modifications will be lost. If you would like to keep updating your theme, and don't want to reinsert our PHP code every time you do that, then you could create a child theme!

So all in all, you just need to find the codepart between your theme's files, and you can put your slider there!

Useful PHP functions

Show up everywhere:
<?php echo do_shortcode('[smartslider3 slider=1]'); ?>
Only on the homepage:
<?php
  if(is_home() || is_front_page()){
    echo do_shortcode('[smartslider3 slider=1]');
  }
?>
Only on that page which has 2 as its ID:
<?php
  if(get_the_ID()==2) {
    echo do_shortcode('[smartslider3 slider=1]');
  }
?>

⚠️ Warning: The get_the_ID() only works on posts and pages! It won't work on categories!

Only on that page which has "Slider Test Page" as title:
<?php
  if(get_the_title()=="Slider Test Page") {
    echo do_shortcode('[smartslider3 slider=1]');
  }
?>
Mix them:
<?php
  if(is_home() || is_front_page() || get_the_ID()==2 || get_the_title()=="Slider Test Page") {
    echo do_shortcode('[smartslider3 slider=1]');
  }
?>

💡 Do you need more dynamic way to show your sliders from your posts?

Create a new widget position instead, or use Advanced Custom Fields plugin mixed with your code.

Advanced shortcode usage

In the examples you will see the 71 number as the slider's ID, but you have to get yours from your slider's shortcode.

Start from a given slide

Example: start from 2nd slide

[smartslider3 slider=71 slide=2]
Start from a variable given in the URL
☝️ Note: This only works, if you are not using cache on your website! If you are using cache, then use our JavaScript only code.

You can put variables into urls, for example: http://example.com/index.php?slide=5

You could use that variable to decide which slide to load first:

[smartslider3 slider=71 get=slide]
Only show the slider on the homepage

[smartslider3 slider=71 page=home]
Only show the slider on the page with the given ID

When you are in your post or page editor, you can read out the ID of the currently edited post/page from the url. For example: http://example.com/wp-admin/post.php?post=2010&action=edit

In this case the page ID is 2010, and with this shortcode my slider will only show up there:

[smartslider3 slider=71 page=2010]
Only show the slider for logged in users

[smartslider3 slider=71 logged_in=1]
Only show the slider for logged out users

[smartslider3 slider=71 logged_in=0]
Only show the slider for the given user role

[smartslider3 slider=71 role=subscriber]

If you are not sure about the exact user role identifier on your website, use a plugin like  User Role Editor and check out the identifiers in it.

Only show the slider for users having the given capability


[smartslider3 slider=71 cap=edit_posts]

WordPress has some default capabilities what you can see here, but you can use User Role Editor to identify all the available capabilities.

Only show the slider on a given language


[smartslider3 slider=71 lang="en_US"]

WordPress has a get_locale function, which returns the language of the currently viewed page. Language plugins should be compatible with this function, so this language identification should work. It is possible, that the languages will be stored similarly as you see it on this list (example: en_US, hu_HU), but if that wouldn't work, try their lowercase versions (example: en_us, hu_hu) or only use the shorter version (en, hu). If you are a developer, this PHP code could tell you the exact value you are looking for:

var_dump(get_locale());

Force the slider to load inside an iframe


[smartslider3 slider=71 iframe="some reason"]

You can force our slider to load inside an iframe, so it wouldn't be affected by any codes coming from your website. This can be a solution for autop problems, too strong CSS codes coming from the theme or custom codes, etc.. The "some reason" can be anything, so you could even write the same "some reason" text. Please note, that if you have one slider loading with iframe, on that page all sliders following it will be loading inside iframes.

Be sure to change 71 with your slider's id.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.