Wrapping php code between opening and closing shortcode in wordpress

I'm using shortcodes for a toggle element and I would like to put the output for the following code inside this toggle element.

<?php function myget_info(){ echo '123';} ?>

The code i am using for the toggle and my function is

<?php echo do_shortcode( '[vc_toggle title="Toggle title"]' . myget_info() . '[/vc_toggle]' ); ?>

However when I use the above, the output from my function, appears on top of my toggle rather than inside my toggle.

-------------Problems Reply------------

The problem you have is you're outputting the value of myget_info() immediately instead of returning it so it can be used inside do_shortcode().


function myget_info() {
echo '123';


function myget_info() {
return '123';

Category:php Views:2 Time:2018-10-09
Tags: php wordpress

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.096 (s). 11 q(s)