Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="slider">
- <ul>
- <?php
- $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
- $sticky = get_option('sticky_posts');
- $args_cat_only = array (
- 'my_cat' => $term->slug,
- 'posts_per_page' => -1,
- 'post__in' => $sticky,
- 'post_type' => MYCPT_POST_TYPE,
- 'post_status' => 'publish',
- 'orderby' => 'rand',
- );
- $cat_only_query = new WP_Query( $args_cat_only );
- if ( $cat_only_query->have_posts() ) {
- while ( $cat_only_query->have_posts() ) {
- $cat_only_query->the_post(); ?>
- <li>
- // items from category only
- </li>
- <?php } wp_reset_postdata();
- if( count($cat_only_query->posts) <= 4 ) {
- $args_all_cats = array ( //Args to pull from all categories
- 'orderby' => 'rand',
- 'posts_per_page' => -1,
- //'my_cat' => $term->slug,
- 'post__in' => $sticky,
- 'post_type' => MYCPT_POST_TYPE,
- 'post_status' => 'publish'
- );
- $cat_query_all = new WP_Query( $args_all_cats );
- if( $cat_query_all->have_posts() ) {
- while( $cat_query_all->have_posts() ) {
- $cat_query_all->the_post(); ?>
- <li>
- // items from ALL categories
- </li>
- <?php } wp_reset_postdata();
- }
- }
- }
- ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement