Custom Post Type, Taxonomy, and Meta Box value, how to sort

I've got a wordpress loop Im working on for a sports website that I'm having an issue with figuring out.

I've created a custom post type called Players I've created a custom Taxonomy called Position (forward, defense, goalie) I've also got some custom meta boxes one being jersey number.

I trying to split the page into 3 sections based on position so I've tried to create a query for each loop. I've written this.

$posts = new WP_Query( array( 
'post_type' => 'players', 
'showposts' => 10, 
'tax_query' => array(
        'taxonomy' => 'position', 
        'field' => 'slug', 
        'terms' => 'forward')
                ));

The second part of the question I had was if it was possible to arrange this query by a meta box value, I ideally would like to orderby jersey number.

I've tried a few suggestions but in every loop I keep getting all the posts from players.

$posts = new WP_Query( array( 
                    'post_type' => 'players', 
                    'showposts' => 10, 
                    'tax_query' => array(
                                    'taxonomy' => 'position', 
                                    'field' => 'slug', 
                                    'terms' => 'forward')
                ));
                while ( $posts->have_posts() ) : $posts->the_post(); ?>
                    <tr class="player">
                        <td class="leftBrdr"><?php the_title(); ?></td>
                        </td>
                    </tr>
                <?php endwhile; ?>
            <?php wp_reset_query(); ?>

Answers


you can also do order by 'menu order' which is available for pages and your cpt if it is defined as 'hierarchical' => true in the register_post_type.


Need Your Help

How do I trap OCUnit test pass/failure messages/events

objective-c unit-testing continuous-integration ocunit

I'm trying to use xcodebuild and OCUnit with my Continuous Integration server (TeamCity).

AutoMapper for Func's between selector types

c# linq

I have two types: Cat and Dog. I'd like to select Cats using a Func&lt;Dog, bool&gt;. To do that, I need a way to map the properties from Cat to Dog in some sort of mapper (similar to how AutoMappe...