当您提到“个人资料”时,我假设您的意思是“作者”。
在 $myposts 中拥有所有帖子后
$myposts = get_posts( $args );
你遍历它们
foreach( $myposts as $key => $post )
(注意我添加了 $key)
现在您可以使用日期作为键创建自己的数组
$my_array[$myposts[$key]->post_date][] = ...whatevever you want in the end
随意添加您想要在最后显示的任何数据。我们以文章的作者和标题为例:
$the_item[$myposts[$key]->post_author] = $myposts[$key]->post_title;
$my_array[$myposts[$key]->post_date][] = $the_item;
这将产生一个如下所示的数组:
[2007-11-19 22:46:37] => Array
(
[0] => Array
(
[3] => Title
[2] => Another title
)
)
[2007-11-11 11:11:11] => Array
(
[0] => Array
(
[3] => Yet another title
[2] => Foo
)
[1] => Array
(
[3] => Bar
[2] => Yuck
)
现在所有帖子都按日期排序,不同作者的帖子“混合”。随意使用任何排序功能(如上所述)。您可能想通过使用 shuffle() 添加一点随机性...为了显示帖子,您将采用相反的方式:遍历您创建的数组并打印您包含的数据(例如作者、标题、内容等)。 )。作为参考,这是 post 对象的样子:
myposts:Array
(
[0] => stdClass Object
(
[ID] => 1455
[post_author] => 3
[post_date] => 2013-03-27 22:16:33
[post_date_gmt] => 2013-03-27 22:16:33
[post_content] => Content
[post_title] => Title
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => title
[to_ping] =>
[pinged] =>
[post_modified] => 2013-03-27 22:16:42
[post_modified_gmt] => 2013-03-27 22:16:42
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://www.abc.com/wordpress/?p=1455
[menu_order] => 0
[post_type] => post
[post_mime_type] =>
[comment_count] => 0
[member_access_visibility] => default
[filter] => raw
)
希望这可以帮助您解决问题!
干杯
京东