admin管理员组文章数量:1406064
Not sure why this is not working. I get no errors, but just shows nothing at all in the text widget. The shortcode works on pages and posts. WordPress version 3.9.1
add_filter('widget_text', 'do_shortcode');
// Shortcode for Widget copyright Year [year]
function copyyear_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'copyyear_shortcode');
Any help would be greatly appreciated.
Not sure why this is not working. I get no errors, but just shows nothing at all in the text widget. The shortcode works on pages and posts. WordPress version 3.9.1
add_filter('widget_text', 'do_shortcode');
// Shortcode for Widget copyright Year [year]
function copyyear_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'copyyear_shortcode');
Any help would be greatly appreciated.
Share Improve this question asked Jul 29, 2014 at 19:28 LorneLorne 131 silver badge5 bronze badges 4- It looks good to me. Did you check the HTML source code or try this on the default theme? – birgire Commented Jul 29, 2014 at 19:54
- I see in the source code that it renders out the php statement instead of the value. Checking in 2012 theme it works. There must be something higher up in my functions file that's causing the conflict. Will check that. – Lorne Commented Jul 29, 2014 at 20:10
- Well, I'll be jiggered! It works after switching to 2012 theme and then back to my own theme. The widget was not updating properly, even though it appeared to be saving when I hit the button. When I switched back to my own theme I noticed the php code in the widget, which should not have been there. Replacing it with the shortcode and updating worked this time. Wierd glitch I guess. Thanks for you time :-) – Lorne Commented Jul 29, 2014 at 20:16
- good to hear you worked it out. – birgire Commented Jul 29, 2014 at 20:26
1 Answer
Reset to default 0Try switching to a different theme (such as 2012) and back to this theme again. Some times caching plugins and some hosting environments can cause issues.
本文标签: Shortcode in Text Widget not working
版权声明:本文标题:Shortcode in Text Widget not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744949422a2633989.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论