custom post types - Add shortcode inside of the_content()

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 sho

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

You 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

相关推荐

  • custom post types - Add shortcode inside of the_content()

    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 sho

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信