0

I'm using redux frmaework for my theme option panel. & I'm using meta slider for my homepage. I used this shortcode in my frontpage template to show the slider:

<?php echo do_shortcode('[metaslider id=21]'); ?>

but I want to change the id from my option panel, so I don't have to edit my template each time I replaced the slider with a new one. I've created a field for that in my redux config page. Now I can use this code:

<?php echo $redux_demo['mslider-id']; ?>

but I don't know how can I add this to my first code. I want to replace the id number "21", with this 2nd code.

2 Answers 2

1

I would rather pass the variable to the id attribute inside the shortcode. You can even decide to remove the id attribute inside the shortcode and make it a static value that you pass to your custom query

For examples and more info about how shortcodes operate, check out the Shortcode API

3
  • thanks for your reply. I already visited, but I'm not a pro in php & still learning. so I didn't find my solution. Sep 15, 2014 at 7:00
  • Post the code to your shortcode. File an edit to your question Sep 15, 2014 at 7:06
  • thanks, but I already solved it. created a variable & passed it, like you suggest before. :) Sep 15, 2014 at 7:24
0

I think this should help, or did you already use this solution?

<?php echo do_shortcode('[metaslider id=' . $redux_demo['mslider-id']; . ']'); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.