Background gallery query
// WP_Query arguments
$args = array (
'post_type' => 'gallery',
'category_name' => 'background_gallery',
'pagination' => true,
'posts_per_page' => '1',
'orderby' => 'rand',
'cache_results' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
);
// The Query
$bg_gallery = new WP_Query( $args );
// The Loop
if ( $bg_gallery->have_posts() ) {
while ( $bg_gallery->have_posts() ) {
$bg_gallery->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();