有几种方法可以做到这一点,这是其中之一
$recent_posts = wp_get_recent_posts( array(
'numberposts' => 20, // Number of recent posts
'post_status' => 'publish', // Show only the published posts
'post_type' => 'product'
));
// array_splice ( array, offset, length )
$sub = array_splice( $recent_posts, 10, 10 );
// Random
shuffle( $sub );
array_splice( $recent_posts, 10, 0, $sub );
// Loop
foreach( $recent_posts as $post ) {
echo $post['ID'] . '<br>';
//echo '<pre>', print_r( $post, 1), '</pre>';
}
wp_reset_query();