Site logo

Archived topic

Problem adding author picture under blog post title

18 replies · Started by Benjamin on May 16, 2020

Viewing posts 16–19 of 19

So I have this in Code Snippets:

add_filter( 'generate_post_author_output', function( $output ) {
    if ( ! is_singular() ) {
        return $output;
    }

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

And this in "additional CSS":

.posted-on .updated {
     display: inline;
 }
 .posted-on a time:nth-child(2) {
     display: none;
 }
 .posted-on a time:first-child:before {
     content: "Updated: ";
 }
 .posted-on a time:last-child:before {
     content: "Published: ";
 }

.byline img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    position: relative;
    vertical-align: middle;
    margin: 0 10px 0 0;
}

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

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

So is the issue that it's showing twice in archives, one on top and one at the bottom?

If so which one would you like to remove?

Sorry, I should have been clearer.

Yes. And I would like to remove the one under the excerpt and category on archive pages (so the bottom one).

This archived topic is closed to new replies.