Archived topic
Entry Meta Style Example 1 - Comment link not showing
5 replies · Started by Mathieu on April 7, 2021
Hello everyone,
I'm a new GeneratePress user and this is my first post.
I've followed the instructions found in the documentation here to change the style of the entry meta for single posts (I chose the example 1).
However the comment link doesn't appear. Is there another code I need to add that I'm missing? I'm using disqus with the Disqus Conditional Load plugin.
This is the current php code I have (I tweaked it to display the last update date):
add_filter( 'generate_post_author_output', function() {
return sprintf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() ),
get_avatar( get_the_author_meta( 'ID' ) )
)
);
} );
add_filter( 'generate_header_entry_meta_items', function() {
return array(
'author',
'comments-link',
'date',
);
} );
add_filter( 'generate_footer_entry_meta_items', function( $items ) {
return array(
'categories',
'post-navigation',
);
} );
// Filter post date to display latest date
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<span class="label">Last updated: </span><time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<span class="label">Last updated: </span><time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
return sprintf( '<div class="posted-on">%s</div> ',
$time_string
);
}, 10, 2 );
Any help will be appreciated.
Thank you!
Mat
Hi Mathieu,
Actually, with the new block element of GP Premium 2.0 and Generablocks plugin, we can achieve the same even better result without coding.
https://wordpress.org/plugins/generateblocks/
Here's a demo video on how to create a custom post meta:
https://youtu.be/Ni3KXdZ5Dl8
Some more videos:
https://www.youtube.com/channel/UCoHk-JZFs1N-iI2DQlIKVnA
Let me know if it helps :)
Hi Ying
I tried with GenerateBlocks but the layout in the page elements is different on the video than in my dashboard. I don't find the same settings on the right as shown in the video once I created the Block Element.
Also, is GP Premium 2.0 out already? I thought it was still in Beta.
Thanks!
Yes, it's still Beta, will be out in April :)
In the video, Leo uses GB pro, but I don't think you'll need GB pro to achieve the same layout.
Can I take a look at what you've built with GB?
I haven't build anything with GB because I couldn't find the settings shown in the video. I was basically stuck on the first step.
That's why I was trying to find another way with PHP code as explained in my initial post, and while waiting for the GP 2.0 to be officially released.
Now, if you're saying it's coming really soon, I might just wait for it.
Thanks.
It's Beta now, the feature development is compeleted, there might be some more bugs than the official release, but it should not break things when updating to the official release.
Or waiting for the official release won't take long either :)