Title: sorting custom posts by title not working
Last modified: August 20, 2016

---

# sorting custom posts by title not working

 *  [emlaser](https://wordpress.org/support/users/emilyemilydaviscom/)
 * (@emilyemilydaviscom)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/sorting-custom-posts-by-title-not-working/)
 * Hello – I have a really simple problem that I can’t seem to find the fix for.
   I’m trying to sort my custom posts (for a list of red wines) by title so that
   they display in alphabetical order, and they refuse to sort in any way except
   publish date. Here’s my query:
 *     ```
       <?php
       $args = array(
       	'menu-item-type' => 'wine red glass',
       	'post_type' => 'food_and_drinks',
       	'post_status' => 'publish',
       	'posts_per_page' => -1,
       	'caller_get_posts' => 1,
       	'orderby' => 'title',
       	'order' => 'ASC'
       );
       $my_query = null;
       $my_query = new WP_Query($args);
       if ( $my_query->have_posts() ) { ?>
       	<?php print '<h4>Red</h4>'; ?>
       	<div class="results">
       		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
        		<div class="menu-item">
        		    <?php $price = get_post_meta($post->ID, 'price', false); ?>
        		    <?php the_title(); ?>
        		    <?php print '— ' . $price[0]; ?>
        		    <?php the_excerpt(); ?>
        		</div>
       	<?php endwhile; ?>
       	</div>
       <?php }
       wp_reset_query();
       ?>
       ```
   
 * The results from the above query display like this:
 * Cabernet Sauvignon — 8/32
    Pascual Toso, Mendoza, Argentina 200
 * Pinot Noir — 8/32
    Domaine des Salices, Francois Lurton, Languedoc 200
 * Merlot — 8/32
    Independent Producers, Washington 2008
 * Pinot Noir — 10/40
    Cote Chalonnaise, Vignerons de Buxy, Burgundy 2008
 * Just in case it’s helpful, here’s my code where I’m registering the custom post
   type in functions.php:
 *     ```
       register_post_type('food_and_drinks', array(
       	'label' => __('Food & Drinks'),
       	'singular_label' => __('Food & Drink'),
       	'public' => true,
       	'show_ui' => true,
       	'capability_type' => 'post',
       	'hierarchical' => false,
       	'rewrite' => false,
       	'query_var' => false,
       	'supports' => array('title', 'editor', 'author', 'custom-fields')
       ));
       ```
   
 * Any ideas? I’m probably missing something pretty simple.
 * Thanks!

The topic ‘sorting custom posts by title not working’ is closed to new replies.

## Tags

 * [custom posts](https://wordpress.org/support/topic-tag/custom-posts/)
 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [emlaser](https://wordpress.org/support/users/emilyemilydaviscom/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/sorting-custom-posts-by-title-not-working/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
