WordPress.org

Support

Support » Plugins and Hacks » Hacks » How can i combine these 2 "query_posts into one output?

How can i combine these 2 "query_posts into one output?

  • query_posts(“showposts=$featured_num&cat=”.get_cat_ID($featured_cat));

    query_posts(array
    (‘post_type’ => ‘page’,
    ‘orderby’ => ‘menu_order’,
    ‘order’ => ‘ASC’,
    ‘post__in’ => (array) get_option(‘feat_pages’),
    ‘showposts’ => (int) $featured_num
    ));

    How can i combine these 2 “query_posts into one output?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Oleg Dudkin

    @olegdudkin

    Hi,
    I think the best option is to combine query results after query was made.
    E.g.

    global $wp_query;
    
    query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
    $_t1  = $wp_query->posts;
    
    query_posts(array
    ('post_type' => 'page',
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'post__in' => (array) get_option('feat_pages'),
    'showposts' => (int) $featured_num
    )); 
    
    $wp_query->posts = array_merge( $_t1, $wp_query->posts );
    $wp_query->post_count = count($wp_query->posts);
    
    // main loop here

    I haven’t tested this, but code should do the trick.

    thanks, i give it a shot and see how i can do 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can i combine these 2 "query_posts into one output?’ is closed to new replies.
Skip to toolbar