Home combining php variable with shortcode in wordpress template
Reply: 0

combining php variable with shortcode in wordpress template

gbda Published in 2018-02-14 11:36:57Z

I have set up a content-slide.php template to replace the featured image with a smartslider 3 slider in Wordpress using the shortcode:

[smartslider3 slider=x]

where 'x' is the id number generated by the smartslider plugin

The template allows the id number to be added via a custom field named 'Slideshow ID' to enable the slide number to be added in edit mode.

I have tried adding the following code to the template:

$slide_id = get_post_meta($post->ID, 'Slideshow ID', true); 
echo do_shortcode('[smartslider3 slider= ' . $slide_id . ']' ); 

The slideshow does appear, however the ']' is being rendered on the page on one of the two slides I have added to the site. I'm very new to php and would really appreciate any help on where I am going wrong.

Many thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.295345 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO