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;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745048480a4608239.html
评论列表(0条)