- This topic has 1 reply, 2 voices, and was last updated 6 years, 9 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
front page › Forums › Community › mycred_sell_this with do_shortcode not working
Hi im trying to use mycred_sell_this in a custom page template with do_shortcode but the include is visible always.
<?php echo do_shortcode('[mycred_sell_this price="5"]'); ?> <? include 'accion.php'; ?><?php echo do_shortcode('[/mycred_sell_this]'); ?>
Thanks
Hi.
I think the issue here is that you are breaking up the shortcode into two by calling the do_shortcode twice. The first time you call it, you have no content defined so the shortcode will close itself. The second time you use it, will return nothing since the shortcode with just a closing tag is not valid.
If you need to load a php file, you might want to buffer the output from your php file and insert it into the shortcode:
ob_start(); include 'accion.php'; $content = ob_get_contents(); ob_end_clean(); echo do_shortcode( '[mycred_sell_this price="5"]' . $content . '[/mycred_sell_this]' );
It really depends on whats inside this custom php file you are including. In the above example, the files content are stored under the $content variable which is inserted into the shortcode.
You must be logged in to reply to this topic.
Start Gamification in Your WordPress site in Minutes. What are you waiting for?
11
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.