[Support request] How we can set post meta (Author name | Comment Count | Last Updated Date) ?

Home Forums Support [Support request] How we can set post meta (Author name | Comment Count | Last Updated Date) ?

Home Forums Support How we can set post meta (Author name | Comment Count | Last Updated Date) ?

  • This topic has 7 replies, 2 voices, and was last updated 4 years ago by Leo.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1210563
    Akash

    How we can set post meta (Author name | Comment Count | Last Updated Date). I also show reference image for more details. Please share code without plugin how we can setup in single post and archive post.

    Image Link: https://prnt.sc/rn5ip7

    #1211101
    Leo
    Staff
    Customer Support

    Hi there,

    Would this be for both blog listing page and single post?

    #1211578
    Akash

    Yes, blog listing page and single post

    #1212161
    Leo
    Staff
    Customer Support

    Hi there,

    Add this PHP snippet:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'comments-link',
    	'date',
        );
    } );
    add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) {
        if ( '' === $item ) {
            return '';
        }
        if ( 'comments-link' === $item ) {
            return ' | ';
        }
        if ( 'date' === $item ) {
            return ' | ';
        }
    
        return $output;
    }, 50, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    And this CSS to start:

    .single .comments-link {
        display: inline-block;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1212696
    Akash

    Thanks for help LEO,

    I have some question:
    1) How we can remove by before author name
    2) How we can add vertical bar after comment (see attached image for more details)

    Image 1: https://prnt.sc/ro8p6j

    3) How we can remove comment count below excerpt in blog listing page (see attached image for more details)

    Image 2: https://prnt.sc/ro8pyk

    #1213264
    Leo
    Staff
    Customer Support

    1) Edit the PHP above:
    https://generatepress.com/forums/topic/how-we-can-set-post-meta-author-name-comment-count-last-updated-date/#post-1212161

    2) How are you adding the last updated date currently? Can you link me to the page in question?

    3) You’d need this filter:
    https://docs.generatepress.com/article/generate_footer_entry_meta_items/

    #1234849
    Akash

    Hi LEO
    2) How are you adding the last updated date currently? Can you link me to the page in question?
    I am using Last modified date using this code:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
        $time_string = '<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 = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated On %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( '<span class="posted-on">%s</span> ',
            $time_string
        );
    }, 10, 2 );

    how we can show vertical bar before last maodified date.

    3) How we can remove meta in blog archive footer.
    For more information see image: https://prnt.sc/rx8blm

    #1235524
    Leo
    Staff
    Customer Support

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.