Created
January 6, 2015 02:03
-
-
Save justiny/de12a59aba8a5dfafea4 to your computer and use it in GitHub Desktop.
Show posts from multiple categories in query using Metabox Deluxe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $categories = rwmb_meta( 'gt_meta_value', 'type=taxonomy&taxonomy=category' ); | |
$cat_num = get_post_meta($post->ID, 'gt_cat_num', TRUE); | |
foreach ( $categories as $category ){ | |
$cat_ids[] = $category->term_id; | |
} | |
$i = 1; | |
if ( get_query_var('paged') ) { | |
$paged = get_query_var('paged'); | |
} else if ( get_query_var('page') ) { | |
$paged = get_query_var('page'); | |
} else { | |
$paged = 1; | |
} | |
query_posts( | |
array( | |
'showposts' => $cat_num, | |
'cat' => implode(",", $cat_ids), | |
'paged' => $paged ) ); | |
if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post(); $count++; ?> | |
Stuff in loop goes here. | |
<?php $i++; endwhile; ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment