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.


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

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

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, privacy policy and cookie policy

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