• Resolved babar_waheed82

    (@babar_waheed82)


    I am trying to sort posts which i am getting from 2 categories. I searched alot on the internet but i didn’t find any solution. Can anyone help me how to do that? At the moment i am using this code here.

    <?php
    query_posts( ‘cat=-1,-2′.’posts_per_page=10′.’&order=ASC’ );
    while ( have_posts() ) : the_post();
    the_title();
    endwhile;
    wp_reset_query();
    ?>
    Please i really need help. Thankyou.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter babar_waheed82

    (@babar_waheed82)

    $arguments = array(‘numberposts’ => 9999, ‘offset’=> 0, ‘category’ => ‘10,11,12,13,14,15’);

    $myposts = get_posts( $arguments );

    I also tried this but it sorts by category example

    a
    b
    c
    a
    b
    c

    Thread Starter babar_waheed82

    (@babar_waheed82)

    Solved…..
    <?php $the_query = new WP_Query( array( ‘category__not_in’ => array( 1,2 ),’posts_per_page’ => -1, ‘offset’ => 1,‘orderby’=>’title’,’order’=>’ASC’ ) );
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to sort POSTS from 2 Categories in ASC or DSCE?’ is closed to new replies.