WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having an issue getting my Custom Post Type "slide" to pick up the custom order set in the order attribute. In fact I can't seem to get the order to change from ASC to DESC period. I have looked all over the net and can't seem to figure this one out, am I missing something?

here is my code..

in my functions.php file:

  $labels = array(
'name' => _x('Home Slideshow', 'post type general name'),
'singular_name' => _x('Slide', 'post type singular name'),
'add_new' => _x('Add New', 'Slide'),
'add_new_item' => __('Add New Slide'),
'edit_item' => __('Edit Slide'),
'new_item' => __('New Slide'),
'view_item' => __('View Slide'),
'search_items' => __('Search Slide'),
'not_found' =>  __('No Slide found'),
'not_found_in_trash' => __('No Slides found in Trash'), 
'parent_item_colon' => '',
'menu_name' => 'Home Slideshow'

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true, 
'show_in_menu' => true, 
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true, 
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail', 'excerpt', 'page-attributes')

And here is my query:

        'post_type' => 'slide',
        'posts_per_page' => -1,
        'orderby' => 'menu_order',
        'order' => 'ASC'


if (have_posts()) :?>
<div class="gallery">
    <a href="#" class="prev">prev</a>
    <a href="#" class="next">next</a>
    <div class="frame">
        <div class="gallery-holder">
            <?php while (have_posts()) : the_post(); ?>             
            <a href="<?php echo get_the_excerpt(); ?>"><div class="slide">
                <?php if(has_post_thumbnail()){
                $src_full = wp_get_attachment_image_src( get_post_thumbnail_id(), 'slide' );
                $src_small = wp_get_attachment_image_src( get_post_thumbnail_id(), 'slide_small' );?>
                <div data-picture data-alt="image description">
                    <div data-src="<?php echo $src_full[0] ?>" ></div>
                    <div data-src="<?php echo $src_small[0] ?>" data-media="(max-width:479px)" ></div>
                    <!--[if (lt IE 9) & (!IEMobile)]>
                        <div data-src="<?php echo $src_full[0] ?>"></div>
                    <!-- Fallback content for non-JS browsers. Same img src as the initial, unqualified source element. -->
                    <noscript><img src="<?php echo $src_full[0] ?>" width="719" height="394" alt="image description" /></noscript>
                <?php } ?>
                <div class="text">
                    <strong class="title"><?php the_title() ?></strong>
                    <div class="content">
                        <?php the_content(); ?>
            </div>  </a>                
            <?php endwhile; ?>
<?php endif; ?>

Any help would be greatly appreciated..
I feel like this is one of those where I am just missing some small thing and it's driving me nuts..

share|improve this question
Have you verified that posts do have order values set? What is resulting MySQL query (try dumping $wpdb->last_query) ? – Rarst Sep 13 '13 at 13:30
I installed your code and it works as expected. There is something else going on. @Rarst's suggestion is the first thing that came to my mind. – s_ha_dum Sep 13 '13 at 13:32

Your Answer


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

Browse other questions tagged or ask your own question.