admin管理员组文章数量:1428474
I want to use this as a shortcode to show in any post/page
<?php
$user_id = get_current_user_id();
if ($user_id == 0) {
echo 'You are currently not logged in.';
} else {
echo 'You are logged in as user '.$user_id;
}
?>
when I do this
// Add Shortcode
function uniqueID_shortcode() {
$user_id = get_current_user_id();
if ($user_id == 0) {
echo 'You are currently not logged in.';
} else {
echo 'You are logged in as user '.$user_id;
}
}
add_shortcode( 'naveen', 'uniqueID_shortcode' );
Gutenberg through an error of Updating failed, how to solve this? Thank you in advance.
I want to use this as a shortcode to show in any post/page
<?php
$user_id = get_current_user_id();
if ($user_id == 0) {
echo 'You are currently not logged in.';
} else {
echo 'You are logged in as user '.$user_id;
}
?>
when I do this
// Add Shortcode
function uniqueID_shortcode() {
$user_id = get_current_user_id();
if ($user_id == 0) {
echo 'You are currently not logged in.';
} else {
echo 'You are logged in as user '.$user_id;
}
}
add_shortcode( 'naveen', 'uniqueID_shortcode' );
Gutenberg through an error of Updating failed, how to solve this? Thank you in advance.
Share Improve this question edited May 4, 2019 at 1:16 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 3, 2019 at 18:28 naveenkharwarnaveenkharwar 234 bronze badges1 Answer
Reset to default 1From add_shortcode
...Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results...
Try changing the echo
s in your callback to return
s and see, if that helps.
本文标签: WordPress User ID as Shortcode
版权声明:本文标题:WordPress User ID as Shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745525052a2661796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论