【发布时间】:2011-03-31 15:48:47
【问题描述】:
如何随机获取作者详细信息和作者页面永久链接。我已经检查了 wordpress 的新 get_users() 函数,它返回了作者,但我不能随机排序它们。
这是我使用代码的网站:http://citystir.com
有什么帮助吗?
解决方案:感谢 theomega 我解决了这个问题。这是社区共享的代码:
$args = array('role' => 'author');
$authors = get_users($args);
shuffle($authors);
$i = 0;
foreach ($authors as $author):
if($i == 4) break;
//do stuff
$i++;
endforeach;
没有设置 $args 的限制,因为我需要在所有用户中进行随机播放。希望它会帮助那里的人,在野外。 :D 谢谢!
【问题讨论】:
标签: php wordpress wordpress-theming