• Hello everyone,
    I’m a bit confused here…

    I’m trying to loop in my custom post type category, all of my categories, and show 2-3 posts per category…

    Do I need a while… or a forearch… or both…
    Here’s what i have so far.

    $args = array(
    'post_type' 		=> 'portfolio',
    'category__not_in' 	=> array( 30, 28 ), // Exclude IDS
    'posts_per_page' 	=> 2, // Number of posts per page I want to show
    'order' 			=> 'DESC', // Order
    );
    
    // The new loop!
    $loop = new WP_Query( $args );
    
    //Display the contents
    if (have_posts()) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    	the_title(); ?>
    	the_post_thumbnail('medium');
    
    endwhile; endif;

    My file’s name is : category-portfolio.php

    Can you help me on this

Viewing 1 replies (of 1 total)
  • I think you need to put the outer query to one side and recover it after you have finished with the inner query. So:

    $outer_query = clone $wp_query;
    // make the child query
    $args = array( etc
    
    $inner_loop = new etc
    
    // now back to the outer loop
    $wp_query = clone $outer_query;

Viewing 1 replies (of 1 total)
  • The topic ‘Double loop, category loop and posts per page’ is closed to new replies.