how to add guest author custom field in wordpress admin

Some times you need people want to add guest author’s articles in your site. So add guest author custom field in wordpress using code so that meta field will be useful to you in future.

how to add guest author custom field in wordpress admin

If you want to add the guest author custom field in wordpress admin. you can use the following code.

You need to open your functions.php file put following code in that.

add_filter( 'the_author', 'guest_author_name' );
 add_filter( 'get_the_author_display_name', 'guest_author_name' );
 function guest_author_name( $name ) {
 global $post;
 $author = get_post_meta( $post->ID, 'guest-author', true );
 if ( $author )
 $name = $author;
 return $name;
 }

 

how to add the guest author custom field in wordpress admin

how to add the guest author custom field in wordpress admin

Add a Comment

Your email address will not be published. Required fields are marked *