0
我的例如 要求 - 我有20个职位(WordPress的) - 我需要10后从升序(从自定义元键排序) - 然后我需要显示随机从已经1个员额模板页面排序(10个)的数据WordPress的排序随机数据已经排序升序
我在function.php
add_filter('the_posts', function($posts, WP_Query $query)
{
if($pick = $query->get('_shuffle_and_pick'))
{
shuffle($posts);
$posts = array_slice($posts, 0, (int) $pick);
}
return $posts;
}, 10, 2);
代码
$args =array('post_type' => 'products',
'posts_per_page' => 10,
'meta_key' => '_showoption_',
'orderby' => 'meta_value',
'order' => 'asc',
'no_found_rows' => 'true',
'_shuffle_and_pick' => 1 ,
);
$my_query = new WP_Query($args);
我的结果:从10上升后1周后:但我需要1个随机从这个10后