Wrapping php code between opening and closing shortcode in wordpress -
i'm using shortcodes toggle element , put output following code inside toggle element.
<?php function myget_info(){ echo '123';} ?>
the code using toggle , function
<?php echo do_shortcode( '[vc_toggle title="toggle title"]' . myget_info() . '[/vc_toggle]' ); ?>
however when use above, output function, appears on top of toggle rather inside toggle.
the problem have you're outputting value of myget_info()
instead of returning can used inside do_shortcode()
.
change:
function myget_info() { echo '123'; }
to:
function myget_info() { return '123'; }
Comments
Post a Comment