Modifier info below post title
-
I want to change the display infomation below the post title like
Published date | Updated date | Author name | Comment Count|Can You help me??
-
Hi there,
You can show the updated date with some CSS:
.posted-on .updated { display: inline-block; }
To rearrange/add items to the top meta area, you can do this:
add_filter( 'generate_header_entry_meta_items', function( $items ) { return array( 'date', 'author', 'comments-link', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array_diff( $items, [ 'comments-link' ] ); } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if you need more info ??
Added and it is become
Updated Date | Published date | Author | Comment |I added this script into php and
add_shortcode( 'comment_number', 'tu_comment_number_sc' ); function tu_comment_number_sc() { ob_start(); comments_popup_link( __( '0 Comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); return ob_get_clean(); } add_filter( 'generate_post_date_output', 'tu_show_modified_date' ); function tu_show_modified_date() { printf( '<span class="posted-on-published"> %1$s %3$s </span>', esc_html( get_the_date() ), esc_attr( get_the_time() ), get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ? '<span class="posted-on-updated"> </span> ' . esc_html( get_the_modified_date() ) : '' ); #echo '<span class="view-post"><i class="fa fa-eye fa-1x " aria-hidden="true"></i></span> ' . do_shortcode( '[views] ' ); echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' ); }
And it become Published date | updated date | Comment Count |like
https://imgur.com/a/7CK7i7t in home page and single postpage with Addition CSSIt is ok in home page but I want in single post page it become Published date | updated date | (icon) Author name (without link) | Comment Count | like https://imgur.com/a/SySGLKh
Is the code I added above is optimize? If not anyway to optimize that?
I want
Now I added more code and in blog setting -> Archives -> unstick “Display post author” and stick in single tab
Now in homepage author name is gone, in single post page author name display but follow this type
Published date | updated date | comment count | Author |But I want
Published date | Updated date | Author | Comment count |The code I added is
add_shortcode( 'comment_number', 'tu_comment_number_sc' ); function tu_comment_number_sc() { ob_start(); comments_popup_link( __( '0 Comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); return ob_get_clean(); } add_filter( 'generate_post_author_output', 'tu_remove_by_byline' ); function tu_remove_by_byline() { printf( ' <span class="byline">%1$s</span>', // WPCS: XSS ok, sanitization ok. sprintf( '<span class="author vcard" itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%3$s</span></a></span>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), /* translators: 1: Author name */ esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); } add_filter( 'generate_post_date_output', 'tu_show_modified_date' ); function tu_show_modified_date() { printf( '<span class="posted-on-published"> %1$s %3$s </span>', esc_html( get_the_date() ), esc_attr( get_the_time() ), get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ? '<span class="posted-on-updated"> </span> ' . esc_html( get_the_modified_date() ) : '' ); #echo '<span class="view-post"><i class="fa fa-eye fa-1x " aria-hidden="true"></i></span> ' . do_shortcode( '[views] ' ); echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' ); }
Is the code I provided above still active? It should keep the order I specified in the function.
What’s the main thing you’re trying to do? Remove the author link on single posts?
I want to add the follow type on single post page
Published date | Updated date | Author-name(no link) | Comment count |On homepage is:
Published date | Updated date | Comment count |What is it currently on single posts?
Published date | Updated date | Author-name(with link) | Comment count
If so, try this: https://docs.generatepress.com/article/generate_post_author_output/#remove-link
Single post is now
Published date | Updated date | Comment count | Author-name(No link)But I want
Published date | Updated date | Author-name(no link) | Comment countIn my function code Comment Count stick with date . My code is
add_shortcode( 'comment_number', 'tu_comment_number_sc' ); function tu_comment_number_sc() { ob_start(); comments_popup_link( __( '0 Comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); return ob_get_clean(); } add_filter( 'generate_post_author_output', 'tu_remove_by_byline' ); function tu_remove_by_byline() { printf( ' <span class="byline">%1$s</span>', // WPCS: XSS ok, sanitization ok. sprintf( '<span class="author vcard" itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%3$s</span></a></span>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), /* translators: 1: Author name */ esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); } add_filter( 'generate_post_date_output', 'tu_show_modified_date' ); function tu_show_modified_date() { printf( '<span class="posted-on-published"> %1$s %3$s </span>', esc_html( get_the_date() ), esc_attr( get_the_time() ), get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ? '<span class="posted-on-updated"> </span> ' . esc_html( get_the_modified_date() ) : '' ); #echo '<span class="view-post"><i class="fa fa-eye fa-1x " aria-hidden="true"></i></span> ' . do_shortcode( '[views] ' ); echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' ); }
That’s happening because you’re appending the comments count to the author output with this line:
echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' );
Are you using my code above?: https://www.ads-software.com/support/topic/modifier-info-below-post-title/#post-12562991
It should move the comments link to the end.
Tried it but removed because it become
Updated date | Published date | author-name | CommentMy wanted style is
Published date | Updated date | author-name | CommentAnd comment count-link do not show on single post page because no option show comment in blog setting
Can you re-add my code then link me to the post? I should be able to provide some CSS to re-order them correctly and show the comments link on single posts ??
I dont my code with that
add_shortcode( 'comment_number', 'tu_comment_number_sc' ); function tu_comment_number_sc() { ob_start(); comments_popup_link( __( '0 Comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); return ob_get_clean(); } add_filter( 'generate_post_author_output', function() { printf( '<span class="posted-on-published"> %1$s %3$s </span>', esc_html( get_the_date() ), esc_attr( get_the_time() ), get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ? '<span class="posted-on-updated"> </span> ' . esc_html( get_the_modified_date() ) : '' ); printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<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' ) ) ) ); echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' ); } ); add_filter( 'generate_post_date_output', 'tu_show_modified_date' ); function tu_show_modified_date() { printf( '<span class="posted-on-published"> %1$s %3$s </span>', esc_html( get_the_date() ), esc_attr( get_the_time() ), get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ? '<span class="posted-on-updated"> </span> ' . esc_html( get_the_modified_date() ) : '' ); echo '<i class="fad fa-comments" aria-hidden="true"></i><span class="comment-post"> ' . do_shortcode( '[comment_number] </span>' ); }
Just enable only date in hompage and only author in single post page
I’m not really sure what you mean. Is that code working as you need?
If not, what needs changing? Can you link me to your site so I can take a look?
- The topic ‘Modifier info below post title’ is closed to new replies.