Theme Integration – Create slider meta box

When you are a theme author you might want to include an option meta box somewhere where you let the user select a slider you put in a page template or similar. This meta box could be build in the theme customizer, the page options or your own theme options page.

In the Options

First we check out if the rev_slider shortcode exists and get the possible value already stored. Use get_post_meta in case you use this snippet on a page/post or get_option when you save this data in your global theme options.

After that build a new RevSlider class. A function from that class called “getArrSliders” gives us all build sliders in return as objects.

The functions “get_alias” and “get_title” linked to this single slider object return the needed values for a selectbox:

In the Template

All you need to do in the template php file is to retrieve the saved meta data (function again depending on where you saved it, post or theme) and put out the shortcode with the right alias inside with the “do_shortcode” function from WordPress.