0

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?

1

You can use the_content Hook: https://developer.wordpress.org/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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.