Advanced Query
-
Hello,
I have the following code which gets 2 posts from 3 different categories and displays them:
$taxonomy = 'category'; $param_type = 'category__in'; $term_args=array( 'include'=> '3,4,11', 'orderby' => 'name', 'order' => 'ASC' ); $terms = get_terms($taxonomy,$term_args); if ($terms) { foreach( $terms as $term ) { $args=array( "$param_type" => array($term->term_id), 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 2, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo 'List of Posts in '.$taxonomy .' '.$term->name; while ($my_query->have_posts()) : $my_query->the_post(); ?>
However, what I need to do is have the posts separated somehow so that I have 2 posts in each
- element.
How would I go about doing this?
Thanks in advance.
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Advanced Query’ is closed to new replies.