• All,

    I’m running a query to return a list of child pages, the related excerpt and featured image thumbnail. The result looks like the following:

    Preview

    As you can see, the list returned isn’t sorted alphabetically, while the side bar is. My code is as follows:

    +++++++++++++++++++++++++++++++

    <h2><?php the_title(); ?></h2>
        <?php $this_page_id=$wp_query->post->ID; ?>
    
    	<?php query_posts(array('order' => 'ASC','showposts' => 20, 'post_parent' => $this_page_id, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
    		<!--begin profile-->
                         <div class="postprofile">
                            <div class="postprofile_photo">
                                <?php if ( has_post_thumbnail() ) {
    the_post_thumbnail();
    } else { ?>
    <img src="<?php bloginfo('template_directory'); ?>/imgs/default_thumbnail.gif" alt="No photo available" title="No photo available" />
    <?php } ?>
                            </div>
                            <div class="postprofile_text">
                                <h4><?php the_title(); ?></h4>
                                <?php the_excerpt(); ?>
            <p><a href="<?php echo get_permalink(); ?>" title="View profile">View profile</a></p>
                            </div>
                            <div class="rien"></div>
                         </div>
                         <!--end profile-->
    
    	 <?php } ?>

    +++++++++++++++++++++++++++++++

    How can I modify the code to have the list display alphabetically by title?

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter 3Plumes

    (@3plumes)

    Defade,

    That cleared things up a bit. Thanks! I changed ‘order’ => ‘ASC’ to ‘order’ => ‘title’ and now I get the following: Preview

    As you will notice, they’re all sorted by title, except one (which has the same format of a name as the others).

    Any ideas why this would be happening?

    Thread Starter 3Plumes

    (@3plumes)

    Not sure what caused it. I deleted the page, and re-created it, and now all works well. Thanks again

    i’m no expert, and it sounds like you got it sorted…

    from your reply i’d say did you change ‘order’ to ‘orderby’

    it actually looks like you need BOTH commands:

    order – chooses the direction of the order
    orderby – chooses what they are sorted by

    so you need:

    'orderby' => 'title', 'order' => 'DESC'

    Thread Starter 3Plumes

    (@3plumes)

    Good point. I added:

    'orderby' => 'title', 'order' => 'ASC'

    Works like a charm. Thanks for the heads up on that.

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Query Problem’ is closed to new replies.