Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1130349
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI have new WordPress (5.0.2) install with the code added to the end of functions.php file:
function testsc(){
return "It is working!";
}
function testsc2(){
return "It is working!";
}
add_shortcode('testshortcode', testsc);
add_shortcode('testshortcode2', 'testsc2');
With Debug Objects plugin installed i can see that short codes are added:
Shortcode: testshortcode Function: testsc
Shortcode: testshortcode2 Function: testsc2
But when i put testshortcode or testshortcode2 in a page it is treated as text.
I use default theme: Twenty Sixteen.
Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI have new WordPress (5.0.2) install with the code added to the end of functions.php file:
function testsc(){
return "It is working!";
}
function testsc2(){
return "It is working!";
}
add_shortcode('testshortcode', testsc);
add_shortcode('testshortcode2', 'testsc2');
With Debug Objects plugin installed i can see that short codes are added:
Shortcode: testshortcode Function: testsc
Shortcode: testshortcode2 Function: testsc2
But when i put testshortcode or testshortcode2 in a page it is treated as text.
I use default theme: Twenty Sixteen.
Share Improve this question edited Jan 4, 2019 at 16:36 hal asked Jan 4, 2019 at 15:04 halhal 1351 silver badge7 bronze badges 8 | Show 3 more comments1 Answer
Reset to default 1Finally it worked.
To ensure that, all following conditions must be met:
- declarations must be in lowercase
- do not use echo but return the content
- square brackets are required even in the shortcode block.
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI have new WordPress (5.0.2) install with the code added to the end of functions.php file:
function testsc(){
return "It is working!";
}
function testsc2(){
return "It is working!";
}
add_shortcode('testshortcode', testsc);
add_shortcode('testshortcode2', 'testsc2');
With Debug Objects plugin installed i can see that short codes are added:
Shortcode: testshortcode Function: testsc
Shortcode: testshortcode2 Function: testsc2
But when i put testshortcode or testshortcode2 in a page it is treated as text.
I use default theme: Twenty Sixteen.
Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI have new WordPress (5.0.2) install with the code added to the end of functions.php file:
function testsc(){
return "It is working!";
}
function testsc2(){
return "It is working!";
}
add_shortcode('testshortcode', testsc);
add_shortcode('testshortcode2', 'testsc2');
With Debug Objects plugin installed i can see that short codes are added:
Shortcode: testshortcode Function: testsc
Shortcode: testshortcode2 Function: testsc2
But when i put testshortcode or testshortcode2 in a page it is treated as text.
I use default theme: Twenty Sixteen.
Share Improve this question edited Jan 4, 2019 at 16:36 hal asked Jan 4, 2019 at 15:04 halhal 1351 silver badge7 bronze badges 8-
Try
'testSC'instead oftestSC(unquoted), when in theadd_shortcode()call. – Sally CJ Commented Jan 4, 2019 at 15:29 - Still not working – hal Commented Jan 4, 2019 at 15:34
-
Did you try with the Shortcode or Code block in the new editor? And you're referring to the theme's
functions.phpfile, right? Try disabling all or certain plugins on your site. – Sally CJ Commented Jan 4, 2019 at 15:39 - I used Shortcode block from new editor. Other blocks generate error during saving. Yes. I am refering to the theme's functions.php. I don't have active any plugin besides Debug Objects. – hal Commented Jan 4, 2019 at 15:51
-
Try using lowercases..
testshortcode. – Sally CJ Commented Jan 4, 2019 at 15:56
1 Answer
Reset to default 1Finally it worked.
To ensure that, all following conditions must be met:
- declarations must be in lowercase
- do not use echo but return the content
- square brackets are required even in the shortcode block.
本文标签: Wordpress functionsphp shortcode is not working
版权声明:本文标题:Wordpress functions.php shortcode is not working 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749044502a2307651.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


'testSC'instead oftestSC(unquoted), when in theadd_shortcode()call. – Sally CJ Commented Jan 4, 2019 at 15:29functions.phpfile, right? Try disabling all or certain plugins on your site. – Sally CJ Commented Jan 4, 2019 at 15:39testshortcode. – Sally CJ Commented Jan 4, 2019 at 15:56