🎉 Happy 4th of July! Get 15% off GP Premium with the discount code: 4THOFJULY2020

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

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

Viewing 11 posts - 1 through 11 (of 11 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
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.