【发布时间】:2013-02-08 10:32:23
【问题描述】:
remove_all_filters('posts_orderby');
$args = array(
'post_type' => 'attachment',
'numberposts' => 6,
'orderby' => 'rand',
'exclude' => get_post_thumbnail_id(),
'post_parent' => $post->ID
);
有人可以向我解释为什么'orderby' => 'rand' 部分不起作用吗?
谢谢!
丹
【问题讨论】:
-
你在哪里使用这些参数?
-
在我的侧边栏中。它是生成一组随机的示例徽标。它适用于所有其他 $args 但不适用于“rand”位
-
你在
wp_query()内部使用它吗? -
没有。我认为这无关紧要,因为它适用于数组的所有其他部分。
-
在 $args 之后,我有 $recent_posts = get_posts($args); foreach( $recent_posts as $recent ){ echo wp_get_attachment_image( $recent->ID, 'full' ); }