[Resolved] I want to Show All Meta in One Line

Home Forums Support [Resolved] I want to Show All Meta in One Line

Home Forums Support I want to Show All Meta in One Line

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #1346739
    Ravi Saive

    I want to show all meta tags in one line in single post article only with below order:

    Avatar – Author Name | Last Updated Date | Categories | Comments

    Please see the image for your reference: https://ibb.co/rtYdC74

    #1347147
    David
    Staff
    Customer Support

    Hi there,

    use this example here:

    https://docs.generatepress.com/article/entry-meta-style/#example-1

    just update this part of the PHP from:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'comments-link',
            'date',
        );
    } );

    to:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date',
            'categories',
            'comments-link',     
        );
    } );
    #1347343
    Ravi Saive

    In which file I need to update…

    #1347523
    Tom
    Lead Developer
    Lead Developer

    This would be added using one of these methods:

    This would be your complete code:

    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',
            'date',
            'categories',
            'comments-link',     
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, [ 'categories', 'comments-link' ] );
    } );

    Then you’d also need to add the CSS listed on the page David linked you to. That CSS can be added using one of these methods: https://docs.generatepress.com/article/adding-css/

    Hope this helps!

    #1347771
    Ravi Saive

    Thanks, David and Tom,

    The given code working fine now…

    I have a few more settings do like I want to display tags and next-previous navigation like the one in this screenshot: https://ibb.co/X7bFV8d

    #1347808
    Ravi Saive

    Also, I have one issue…

    I have created a hook for Related Posts and added CSS to child theme style.css file, but the CSS is not working, but the same CSS working if I add in Customize Additional CSS section.

    #1347969
    David
    Staff
    Customer Support

    Hi there,

    could you create new separate topics for those request. This one can then be marked as resolved.

    #1350322
    Ravi Saive

    Hi David and Tom,

    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',
            'date',
            'categories',
            'comments-link',     
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, [ 'categories', 'comments-link' ] );
    } );

    The above code is working great, but I just want to remove the author image only from the above code.

    #1350859
    Tom
    Lead Developer
    Lead Developer

    This is it without the avatar:

    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"><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() )
            )
        );
    } );
    
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date',
            'categories',
            'comments-link',     
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, [ 'categories', 'comments-link' ] );
    } );
    #1351243
    Ravi Saive

    Hi Tom,

    Thanks, it worked, great support and great theme ๐Ÿ™‚

    #1351852
    Tom
    Lead Developer
    Lead Developer

    Thanks! ๐Ÿ™‚

    #2069661
    Ravi Saive

    Hi David and Tom,

    I have updated the GP theme to Version: 3.1.0 and the above code is not working…

    Before update – https://ibb.co/Jz6rYk1

    After update – https://ibb.co/5Y6Y3Nv

    Total comments count not showing after update..

    #2069739
    David
    Staff
    Customer Support

    Hi there,

    can you share a link to a post where i can see the issue ?

    #2070781
    Ravi Saive

    Hi David,

    I am testing on a staging server, so can’t be possible to give access, but you can check the Live site at:

    Live site – https://ibb.co/478YXkb [Where total comments count showing]

    Staging Site – https://ibb.co/pxwW8tQ [where total comments count not showing]

    #2070786
    Elvin
    Staff
    Customer Support

    Hi there,

    Can you tell us how you’ve added the PHP snippet?

    If you’ve placed the snippet inside the theme’s functions.php, it would make sense why the changes applied prior to the update were removed because updating the theme overrides the edited functions.php with a fresh functions.php from 3.1.

    Here’s how you should be adding the PHP snippet so it’s unaffected by theme updates –
    https://docs.generatepress.com/article/adding-php/

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