Including php code within a shortcode – help!
-
Hi guys
I am struggling with what is probably quite a simple bit of PHP and wondering if anybody could help?
I have a shortcode embedded in my template – working perfectly…
<?php echo do_shortcode('[mwi_product sku="" title="true" title_tag="h2" desc="true" img="true" img_width="200" price="true" type="add" btn_color="blue" btn_link="button" cols="3"/]'); ?>
(This is the shortcode for Magento WordPress integration – https://magentowp.com)
<<< Notice that the ‘mwi_product sku’ box is empty. I want the client to be able to update this info easily themselves using custom metaboxes in the theme settings. For this I have a piece of php which calls the SKU information from a text metabox:
<?php $options = get_option('sample_theme_options'); echo $options['teaskus']; ?>
Soooo basically I want to merge the two items above. I am hoping I could do something like the following but it breaks the template:
<?php echo do_shortcode('[mwi_product sku="' . $options = get_option('sample_theme_options'); echo $options['teaskus']; . '" title="true" title_tag="h2" desc="true" img="true" img_width="200" price="true" type="add" btn_color="blue" btn_link="button" cols="3"/]'); ?>
Any ideas?? Thanking all you wonderful WordPressers in advance.
- The topic ‘Including php code within a shortcode – help!’ is closed to new replies.