When user post’s any post in the wordpress without registration , their name can be saved in the custom fields but during the display in the front end , posted by section we won’t be able to display his/her name. Here is the solution how to show the posted by section with the custom fields.
Go to fuctions.php and just add the following filter with the author name.
add_filter( 'the_author', 'custom_author_name' ); add_filter( 'get_the_author_display_name', 'custom_author_name' ); function custom_author_name( $name ) { global $post; $author = get_post_meta( $post->ID, 'news_posted_by', true ); if ( $author ){ $name = $author; } return $name; }
Make sure the custom field news_posted_by exist in the corresponding post.