This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

How to output slider shortcode in a template file

  • Creator
    Topic
  • #19134
    ryuchix
    Participant

    hi there..

    is there a chance to insert the shortcode in a theme. i have this slider name pinoyslide.. and shortcode usage is [slider id=”pinoyslide”].. i put it on a theme. single.php and archive.php but its only showing the code.. and not showing the slider.

    im not really into coding so i don’t know what to do.

    thank you in a advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #19136
    Jason Bobich
    Keymaster

    Hello,

    The short answer to your question is that you’d just use WordPress’s do_shortcode function.

    <?php echo do_shortcode('[slider="pinoyslide"]'); ?>

    But realistically making edits directly to files like single.php and archive.php directly in the theme for something like this probably isn’t the best approach, and is probably going to give you problems down the line if you ever want to update the theme. If you’d like to tell me more about what you’re trying to accomplish, I could probably give you a better a approach for getting that slider outputted where you want, using a child theme.

    #19138
    ryuchix
    Participant

    My only purpose is to put the slider in single.php and archive.php.. Since the shortcode doesn’t work on theme. That’s why I asked.. Btw, yes I’m using child theme.

    #19141
    Jason Bobich
    Keymaster

    The main themes files like single.php and archive.php often change with updates. So by copying these to your child theme, you’re just at higher risk of future updates not going as smoothly. A more safe approach is just to hook it to one of the many actions available.

    http://dev.themeblvd.com/tutorial/primary-framework-action-hooks/

    For example, from your child theme’s functions.php, you could do this:

    function my_slider() {
    	if ( is_single() || is_archive() ) {
    		echo do_shortcode('[slider="pinoyslide"]');
    	}
    }
    add_action('themeblvd_content_top', 'my_slider');

    Anyway, just a suggestion. 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The forum ‘The Arcadian Responsive WordPress Theme’ is closed to new topics and replies.