I'm trying to retrieve some values stored in the option panel of WordPress, however the list of the options I found on the site seems not complete. Perhaps it's me looking in the wrong place.
What for getting the name of the author of a given post?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
Options are for general settings not specific to a post. To get the name of the author of a post, you will need to first get the ID of the author from the
$post object and then use that to create a
$user object from which the name can be retrieved.
global $post; $user_id = $post->post_author; $user = new WP_User( $user_id ); $display_name = $user->display_name; $first_name = $user->first_name; $last_name = $user->last_name;
The Options Reference doesn't seem not complete, it is not complete. Have you seen the big notice in the page you linked?
Anyway, it you want to get the name of the author of a given post you are looking in the wrong place. The author of a post is not a option, i.e., it is not a preference or configuration setting. Instead, author is a property of the post object. You can get the author of a given post in various ways. For example, if you are inside the loop you can use get_the_author() function.
Example outside the loop:
//get the $post object of the post with ID 54 $post = get_post(54); //the author info (return a WP User object) $author_info = get_userdata($post->post_author); echo $author_info->display_name;