WordPress.org

Ready to get started?Download WordPress

Forums

author name displayed twice (1 post)

  1. barlas
    Member
    Posted 5 years ago #

    I was just making a simple plugin, that should show name of guest author instead of real author, if there is custom field set, but when I activate the plugin it shows name of author (or guest author) twice on every post. Here's the code:

    function guest_author( $author = '' ) {
    	$guestName = get_post_custom_values( "guestName" );
    
    	if ( $guestName ) {
    		echo $guestName[0];
    	} else {
    		echo $author;
    	}
    }
    
    add_filter ( the_author, guest_author );

    Commenting echo statement doesn't give any output, otherwise it prints them (guestName or author, depending on the if condition) twice, which most probably means for some reason the function is called two times, instead of one.

    Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic