Remove “by” when displaying author name

You can include “by [the author name]” in the Display Posts listing by adding include_author="true" to your shortcode.

If you’d like to remove the “by” and only display the author name, add the code below to your theme’s functions.php file.

This code snippet goes in a core functionality plugin or Code Snippets.

/**
 * Display Posts - Remove "by" from author name
 *
 * @param string $author Author.
 */
function be_dps_remove_by_author( $author ) {
	$author = str_replace( '<span class="author">by ', '<span class="author">', $author );
	return $author;
}
add_filter( 'display_posts_shortcode_author', 'be_dps_remove_by_author' );

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.