Site logo

Archived topic

Removing author avatar

11 replies · Started by gedosan on December 21, 2018

Viewing posts 1–12 of 12

Hi there

I'm using a snippet to format my 'post info' below my page title. I'd like to remove the avatar, so it's just AUTHOR NAME | DATE without the author pic.

Here's the snippet if it makes things quicker:

add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_show_comments', '__return_false' );
add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
function tu_fancy_byline( $date ) {
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<span class="author-name" itemprop="name">%3$s</span></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' ) )
)
);

if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span>';
}

echo $date;
}

Hi there,

Try this:

add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_show_comments', '__return_false' );
add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
function tu_fancy_byline( $date ) {
	printf( ' <span class="byline">%1$s</span>', // WPCS: XSS ok, sanitization ok.
		sprintf( '<span class="author vcard" itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
			/* translators: 1: Author name */
			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
			esc_html( get_the_author() )
		)
	);

	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
			comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
		echo '</span>';
	}

	echo $date;
}

thanks - could u tweak the code and add a 'by' before the author please?

Wouldn't that be the default style?

You shouldn't need the PHP snippet at all.

i thought the default was 'published date' not 'last updated' date though?

Also, just noticed on mobile it looks really big. Can u share with me the CSS to bring it down in size a touch too please?

Thanks

Thanks Tom - I still need the PHP snippet to inject the author (so its author | date) right?

- I wanted to add the word 'by' so it's 'by author | date'
- I wanted the CSS so I can reduce the size of both (especially on mobile, they show up huge)

Thanks guys

G

You shouldn't need PHP for that.

You just need to do this:

.entry-header .entry-meta {
    display: flex;
}

.entry-header .entry-meta .byline {
    order: -10;
}

.entry-header .entry-meta .byline:after {
    content: " | ";
    padding-right: 5px;
}

Thanks Tom, that works. How do I stop the date being a hyperlink? Also the author link just goes back to the homepage?

Thanks for all the help :-)

Thanks Tom, all done.

Cheers

Glad I could help :)

This archived topic is closed to new replies.