Answer the question
In order to leave comments, you need to log in
Why can't I get the author's id from the get_post() array?
Hello, this design does not cause an error.
echo '<pre>';
$post_info = get_post();
var_dump($post_info);
echo '</pre>';
echo '<pre>';
$post_info = get_post();
var_dump($post_info["post_author"]);
echo '</pre>';
object(WP_Post)#10012 (24) {
["ID"]=>
int(802)
["post_author"]=>
string(1) "1"
["post_date"]=>
string(19) "2020-05-25 15:14:45"
["post_date_gmt"]=>
string(19) "2020-05-25 12:14:45"
["post_content"]=>
string(0) ""
["post_title"]=>
string(2) "01"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(6) "closed"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(2) "02"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2020-05-25 15:14:45"
["post_modified_gmt"]=>
string(19) "2020-05-25 12:14:45"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(37) "http://localhost/test/post/0/"
["menu_order"]=>
int(0)
["post_type"]=>
string(11) "adress"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question