on my main page I'd like to be able to make a query of random posts that are consistent throughout a pagination. i have found sevral explanations that uses 'wp_query', but i am looking for a solution that will help me with 'get_posts'.
this is the code i got so far:
foreach ( $categories as $category ) {
global $post;
$myposts = get_posts(array(
'post_type' => 'portfolio',
'orderby' => 'rand',
'posts_per_page' => 1,
'numberposts' => -1, // get all posts.
'tax_query' => array(
array(
'taxonomy' => 'portfolio_categories',
'field' => 'id',
'terms' => $category->cat_ID
)
)
));
foreach ( $myposts as $post ){
setup_postdata( $post );
// stuff of posts
}
wp_reset_postdata(); }