admin管理员组文章数量:1406974
I have a custom post type (events) and i made a custom template for archive and for single.
On single i want to add a shortcode to every post, this shortcode provides all dynamic data of the current post.
How can i input the shortcode in the_content() function?
I have a custom post type (events) and i made a custom template for archive and for single.
On single i want to add a shortcode to every post, this shortcode provides all dynamic data of the current post.
How can i input the shortcode in the_content() function?
Share Improve this question asked Oct 28, 2019 at 20:53 LovinQuaQuaLovinQuaQua 733 silver badges18 bronze badges1 Answer
Reset to default 1You can use the_content Hook: https://developer.wordpress/reference/hooks/the_content/
add_filter( 'the_content', 'my_shortchode_in_single_page' );
function my_shortchode_in_single_page($content){
if(is_single())
return $content . do_shortcode('YOUR SHORTCODE HERE');
return $content;
}
本文标签: custom post typesAdd shortcode inside of thecontent()
版权声明:本文标题:custom post types - Add shortcode inside of the_content() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745048480a2639506.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论