[Resolved] Edit Enty Meta of Blog Post

Home Forums Support [Resolved] Edit Enty Meta of Blog Post

Home Forums Support Edit Enty Meta of Blog Post

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1589184
    Johnson

    Hey,

    Trust you’re good and doing well!

    I want to change the entry meta of each blog post to this form:

    By (author gravatar) Author Name / Last Updated: Mar 24, 2016

    Any help would be much appreciated!

    Thanks!
    Johnson

    #1589470
    David
    Staff
    Customer Support

    Hi there,

    try adding this PHP Snippet:

    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',
        );
    } );

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

    And then add this CSS:

    .byline img {
        width: 25px;
        height: 25px;
        border-radius: 50%;
        position: relative;
        vertical-align: middle;
        margin: 0 10px 0 0;
    }
    
    .posted-on {
    	border-left: 1px solid #ddd;
    	padding-left: 10px;
    	margin-left: 10px;
    }
    #1589517
    Johnson

    Hey David,

    Thank you for your quick support.

    The author gravatar is a square as you can see from my website (offered in private information). Please offer a circular gravatar

    And could you please make it in this form:

    By (author gravatar) Author Name / Last Updated: Mar 24, 2016

    Thank you very much!
    Johnson

    #1589534
    David
    Staff
    Customer Support

    I just checked and the Avatar is round – maybe try clearing the browser cache.

    Now to update the date add this PHP snippet:

    add_filter( 'generate_post_date_show_updated_only', '__return_true' );
    add_filter( 'generate_post_date_output','tu_add_to_post_date' );
    function tu_add_to_post_date( $output ) {
        return ' | Last updated: ' . $output;
    }
    #1589541
    Johnson

    Thanks David! The gravatar is wonderful!

    Could you please help add “Last Updated” behind the “|”

    #1589596
    David
    Staff
    Customer Support

    Oops sorry – remove this CSS:

    .posted-on {
        border-left: 1px solid #ddd;
        padding-left: 10px;
        margin-left: 10px;
    }

    And i have updated the PHP snippet here to include the |

    https://generatepress.com/forums/topic/edit-enty-meta/#post-1589534

    #1590010
    Johnson

    Thank you so much David! You’re a genius!

    #1590301
    David
    Staff
    Customer Support

    Glad to be of help

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