Adding a slider to your page

There are several ways to add a slider to your page or post.

Shortcode

Add [super_hero_slider slider=99] anywhere in your content where sliderĀ is the ID number of your slider.

More simply, if you insert [super_hero_slider] the slider will look for an ID number saved to your post/page meta in the Slider ID field that is automatically added to every post and page.

As featured image

You can replace the featured image on your page or post with a slider. Just select the slider in the ‘Slider’ dropdown field then check the ‘Replace featured image?’ box. Make sure you have added a featured image as a placeholder. There’s more information here.

PHP

Add <?php super_hero_slider(); ?> to a page template.

Or add <?php super_hero_slider(99); ?> to a page template. Note that if you specify a parameter (e.g. 99) this will always display the slider with the ID. If you omit the parameter, Super Hero will use the slider ID specified in the page or post metabox.

WordPress Hook

This is a neat way to add your slider. Depending on what hooks your theme supports, add something like this to your functions.php file.

add_action ( 'your_theme_hook', 'super_hero_slider' );

Every time the your_theme_hook fires, Super Hero will add a slider – if one is specified in the page or post Slide ID field.

You can add a hook to your theme by editing the theme files. For example, if you wanted to add a hook at the top of the page content in the Twenty Sixteen theme, you can edit the header.php file, adding as the final line:

do_action ( 'your_theme_hook' );

This tells your theme to fire any functions associated with this hook.

Remember: if you’re editing theme files, it’s usually best practice to create a child theme first. This will avoid having to re-edit files every time your theme has an update.