admin管理员组文章数量:1201415
Trying to start writing some plugins, however everytime i use the shortcode that calls my function plugin, the function ends up above the header on that page, instead of right where i placed the shortcode.
Here is an example of what i used:
Trying to start writing some plugins, however everytime i use the shortcode that calls my function plugin, the function ends up above the header on that page, instead of right where i placed the shortcode.
Here is an example of what i used:
Share Improve this question asked Apr 12, 2022 at 22:51 Ironside GamingIronside Gaming 1 1- Please don't paste in a screenshot of your code; paste in the actual code, which will be more accessible and also much easier for us to diagnose. – Pat J Commented Apr 12, 2022 at 23:45
1 Answer
Reset to default 0Shortcodes should return
their content, never echo
it.
From the add_shortcode()
docs:
Note that the function called by the shortcode should never produce an 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.
But the functions you appear to be using—the_title()
and the_date()
—both echo
their output by default. Consider using get_the_title()
and get_the_date()
instead. You'll need to refactor some of the rest of your code too, but this should be a good starting point.
本文标签: My plugins are ending up above the header
版权声明:本文标题:My plugins are ending up above the header? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738630465a2103714.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论