admin管理员组文章数量:1406063
I am trying to debug a shortcode. I have written the following function and placed in my theme's functions.php file:
function michael_function_shortcode() {
return 'This is the return';
}
I have defined the shortcode as follows:
add_shortcode(‘michael’, ‘michael_function_shortcode’);
And I have included the shortcode on a page:
[michael]
I know the function is there because if I introduce errors I get messages because of debug=true, but [michael]
just displays and is not replaced by 'This is the return" as expected.
Where do I go from here? How do I debug this?
I am trying to debug a shortcode. I have written the following function and placed in my theme's functions.php file:
function michael_function_shortcode() {
return 'This is the return';
}
I have defined the shortcode as follows:
add_shortcode(‘michael’, ‘michael_function_shortcode’);
And I have included the shortcode on a page:
[michael]
I know the function is there because if I introduce errors I get messages because of debug=true, but [michael]
just displays and is not replaced by 'This is the return" as expected.
Where do I go from here? How do I debug this?
Share Improve this question edited Jun 29, 2018 at 6:19 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jun 29, 2018 at 3:35 mkstlwtzmkstlwtz 1411 gold badge1 silver badge5 bronze badges 2 |1 Answer
Reset to default 1From reading this guide, could you try using a variable to output the return as such?
$output = 'This is the return';
return $output;
Also, if you're calling the shortcode with do_shortcode('[michael]');
in a php file, you'll need to echo
this, like so:
<?php echo do_shortcode('[michael]'); ?>
本文标签: shortcodeHow do I debug a short code
版权声明:本文标题:shortcode - How do I debug a short code? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744959922a2634590.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
‘
and’
, or just'
? – Jacob Peattie Commented Jun 29, 2018 at 3:51