- This topic has 9 replies, 2 voices, and was last updated 5 years ago by
Elvin.
-
AuthorPosts
-
October 2, 2017 at 2:41 am #395726October 2, 2017 at 9:23 am #395947
Tom
Lead DeveloperLead DeveloperHey Paul,
This is what the template tags are for. The only one that doesn’t exist is the comments number, but we can create a shortcode for that:
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 this inside your Page Header:
<div class="page-header-meta"> <span><i class="your-icon"></i> {{post_author}}</span> <span><i class="your-icon"></i> {{post_date}}</span> <span><i class="your-icon"></i> [comment_number]</span> </div>You can learn more about template tags here: https://docs.generatepress.com/article/page-header-template-tags/
October 2, 2017 at 10:05 am #395989Paul
Thanks Tom! I’ve not added it to the site mentioned above yet, but I have tested it on another and it works perfectly 🙂
February 27, 2019 at 1:44 am #822983Dr Wealth
Where should I add this to? :
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();
}February 27, 2019 at 5:01 am #823150David
StaffCustomer SupportHi there,
the code is PHP:
https://docs.generatepress.com/article/adding-php/
If you’re not using a Child Theme then the Code Snippets that is linked in the article is the easiest way.
September 28, 2020 at 3:42 pm #1462924George
Can the comment count output “0” instead of “Leave a comment” when there are no comments?
September 28, 2020 at 3:45 pm #1462926George
Ok, I guess, updating
Leave a commentto0in the function will do!September 28, 2020 at 6:56 pm #1463008Elvin
StaffCustomer SupportHi George,
Have you solved your concern?
If you need further help with this, please open a new topic as it looks like the original topic is resolved. Thank you.
September 29, 2020 at 10:18 am #1464177George
Apologies, I am sorted, thank you!
September 29, 2020 at 1:42 pm #1464426Elvin
StaffCustomer SupportNo problem.:)
-
AuthorPosts
- You must be logged in to reply to this topic.