Skip to main content

First, need to lose query_posts() - it should never be used for secondary loops.

Try something like this:

$posts = get_posts( array(
    'cat' => $category->term_id,
    'posts_per_page''numberposts' => 3,
    ));

foreach( $posts as $post ) {
    
    $listing_code .= get_permalink( $post->ID ); //or whatever
}

First, need to lose query_posts() - it should never be used for secondary loops.

Try something like this:

$posts = get_posts( array(
    'cat' => $category->term_id,
    'posts_per_page' => 3,
    ));

foreach( $posts as $post ) {
    
    $listing_code .= get_permalink( $post->ID ); //or whatever
}

First, need to lose query_posts() - it should never be used for secondary loops.

Try something like this:

$posts = get_posts( array(
    'cat' => $category->term_id,
    'numberposts' => 3,
    ));

foreach( $posts as $post ) {
    
    $listing_code .= get_permalink( $post->ID ); //or whatever
}
Source Link
Rarst
  • 99.9k
  • 10
  • 160
  • 298

First, need to lose query_posts() - it should never be used for secondary loops.

Try something like this:

$posts = get_posts( array(
    'cat' => $category->term_id,
    'posts_per_page' => 3,
    ));

foreach( $posts as $post ) {
    
    $listing_code .= get_permalink( $post->ID ); //or whatever
}