Site logo

Archived topic

Comments number in Page Header

3 replies · Started by Gabriele on August 27, 2017

Viewing posts 1–4 of 4

Hi,
I'm using the new "Page Header" function to build my post page. I inserted post title and post date in the post header, I would like to insert the comment number, I find it very useful, but it's not in the options. Is it possible to add it?
Thanks a lot and greetings,
Gabriele

Hi there,

You'd have to create a shortcode:

add_shortcode( 'comment_number', 'tu_comment_number_sc' );
function tu_comment_number_sc() {
    ob_start();
    comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
    return ob_get_clean();
}

Then add [comment_number] into your Page Header :)

Thanks Tom, it works!

You're welcome :)

This archived topic is closed to new replies.