How can I display these posts in ascending order?

I am trying to display some posts in ascending order beginning with the first created and ending with the most recently created post. Any help is appreciated. Here is my code:

?php
$numofmebers = '-1';
if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1;
    $count_post = 0;
        query_posts( array( 'posts_per_page' = '-1', 'post_type' = 'coach-instructor' ,'post_status' = 'publish') );
        while ( have_posts()) : the_post();
            $count_post++;
        endwhile;
            if ( $node-instructor_pagination == Single Page ) {$node-instructor_page_num = -1;}
            query_posts( array('posts_per_page' = $node-instructor_page_num, 'paged' = $_GET['page_id_all'], 'post_type' = 'coach-instructor' ,'post_status' = 'publish') ); 
        $counter_news = 0;
        while ( have_posts()) : the_post();
        $counter_news++;
        $image_id = get_post_thumbnail_id ( $post-ID );
        $coach_istructor_meta = get_post_meta($post-ID, cs_coach_istructor_meta, true);
            if ( $coach_istructor_meta   ) {
                $xmlObject_author = new SimpleXMLElement($coach_istructor_meta);
                    $about = $xmlObject_author-about;
                    $specialism = $xmlObject_author-specialism;
                    $qualifications = $xmlObject_author-qualifications;
                    $philosophy = $xmlObject_author-philosophy;
                    $contact = $xmlObject_author-contact;
            }
            else {
                $about = '';
                $specialism = '';
                $qualifications = '';
                $philosophy = '';
                $contact = '';
            }
?

Topic posts Wordpress

Category Web


Keep in mind that query_posts is best avoided as it has negative effects on the main loop. A better approach would be a new instance of WP_Query or changing the query arguments for the main loop.

To get the order you want, try adding the following to your args:

array( 'posts_per_page' => '-1', 'post_type' => 'coach-instructor' ,'post_status' => 'publish', 'orderby' => 'date', 'order' => 'ASC')

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.