Site logo

Archived topic

Entry meta one below the other

3 replies · Started by Diogenes on October 29, 2018

Viewing posts 1–4 of 4

Hi.

I have my entry meta with the image of the author with this code:

add_filter( 'generate_post_author_output', 'tu_add_author_gravatar' );
function tu_add_author_gravatar() {
	printf( ' <span class="byline">%1$s</span>',
		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s %5$s<a href="%2$s" title="%3$s" rel="author"><span class="author-name" itemprop="name">%4$s</span></a></span>',
			__( 'by','generatepress'),
			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' ) )
		)
	);
}

But the metadata is in a single line horizontally.

Is it possible to achieve that the meta of the author and the date are one below the other, with the image of the author of the post on the left, as shown in the following image?

[img]http://img.fenixzone.net/i/eSR5MNY.png[/img]

Thanks for the help.

Tough one!

Let's try this as your function:

add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', function( $date ) {
    printf( 
        '<span class="meta-gravatar">%s</span>',
        get_avatar( get_the_author_meta( 'ID' ) )
    );

    echo '<span class="meta-data">';

    printf( ' <span class="byline">%1$s</span>',
        sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s<a href="%2$s" title="%3$s" rel="author"><span class="author-name" itemprop="name">%4$s</span></a></span>',
            __( 'by','generatepress'),
            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() )
        )
    );

    echo $date;

    echo '</span>';
} );

Then let me know and I'll be able to finish it up with some CSS :)

It works perfect.

I made some adjustments and it works great.

Thanks for the help.

You're welcome :)

This archived topic is closed to new replies.