admin管理员组文章数量:1410674
I am having trouble retrieving an array item from WordPress revisions array. I have Googled and no answer I have come across has worked so far. What I am trying to do is create a list of all Authors who have done revisions of a post so I can display this in a dashboard. The rest I can complete just having issues getting the item from the array.
$arrayz = '[0]=>
object(WP_Post)#4970 (24) {
["ID"]=>
int(224)
["post_author"]=>
string(1) "1"
["post_date"]=>
string(19) "2019-11-18 23:93:39"
["post_date_gmt"]=>
string(19) "2019-11-18 23:13:39"
["post_content"]=>
string(24) "New content added here"
}';
echo '<pre>';
var_dump($arrayz);
echo '</pre>';
// Getting error here
echo $arrayz[0]["post_author"];
I am having trouble retrieving an array item from WordPress revisions array. I have Googled and no answer I have come across has worked so far. What I am trying to do is create a list of all Authors who have done revisions of a post so I can display this in a dashboard. The rest I can complete just having issues getting the item from the array.
$arrayz = '[0]=>
object(WP_Post)#4970 (24) {
["ID"]=>
int(224)
["post_author"]=>
string(1) "1"
["post_date"]=>
string(19) "2019-11-18 23:93:39"
["post_date_gmt"]=>
string(19) "2019-11-18 23:13:39"
["post_content"]=>
string(24) "New content added here"
}';
echo '<pre>';
var_dump($arrayz);
echo '</pre>';
// Getting error here
echo $arrayz[0]["post_author"];
Share
Improve this question
asked Nov 19, 2019 at 22:31
SamSam
3871 silver badge7 bronze badges
4
|
1 Answer
Reset to default 1To get the post author ID you can try:
$revisions = wp_get_post_revisions($post->ID);
//For first author
$first_author = $revisions[0]->post_author;
//to get all revision authors
foreach( $revisions as $revision ){
echo $revision->post_author;
}
本文标签: Obtaining array item from WordPress revisions output
版权声明:本文标题:Obtaining array item from WordPress revisions output 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744989704a2636309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
var_dump($arrayz[0])
? – czerspalace Commented Nov 20, 2019 at 0:21