Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to display the following posts in descending order beginning with the first created and ending on the last page 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 = '';
            }
?>
share|improve this question
1  
Ascending or descending? –  toscho Jan 1 '13 at 0:52
add comment

1 Answer

up vote 0 down vote accepted

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')
share|improve this answer
    
Thank you for the help. It worked. I'm still learning PHP and operating within the Wordpress framework. This will help me in the future as well. –  Tom Geoco Jan 1 '13 at 1:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.