Skip Navigation

[Résolu] Custom post order

This support ticket is created Il y a 4 années et 6 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 réponses, has 2 voix.

Last updated by marc-andre Il y a 4 années et 6 mois.

Assigned support staff: Christian Cox.


Here is what i whant

i have create a custom taxonomy called : type-de-partenaire
it like gold-silver-bronze (level of parnership)

and i had create a custom post type : partenaire (partnership)

I what to sort partenaire by type-de-partenaire
so here is my code

$partenaires->query( array(
'posts_per_page'=> '-1',
'orderby', 'meta_value',
'meta_key', 'type-de-partenaire'
) );
here is the result.... all the second level, shold be regroup ad the order of the first level
hidden link
now the first on is Jean-Coutu -> platine, and should be Honda -> emerites


Hi, meta_key and meta_value represent custom fields, not taxonomy terms. It is not possible to sort a WordPress query by taxonomy term. See the documentation for WP_Query Orderby here:
There are no options to sort WP_Query by a taxonomy term, because it is not possible. Instead, you could create a custom field with 3 options - gold, silver, and bronze. Then sort using this custom field instead of the taxonomy. If a taxonomy term is required on your site for some other reason, then you must use custom code to sync the selected term and custom field whenever the post is created or updated.


Here is my final code that work as ask... i whant to share it with the world

add_shortcode( 'list_taxonomy', 'list_taxonomy' );
function list_taxonomy( $atts ) {

$output = '';

$taxonomy = $atts['taxonomy'];
$type = $atts['type'];

//get the taxonomy terms
$terms = get_terms( $taxonomy );
foreach ($terms as $term){ echo $term->name.'<br/>'; }
echo '<hr><br/>';

//$nb = wp_count_posts('ressource');

foreach ($terms as $term){
$args = array(
'post_type' => $type,
'tax_query' => array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term->slug,

$list = new WP_Query( $args );


$output .= '<h2>'.$term->name.'</h2>';

while ($list->have_posts()) : $list->the_post();

$list_image = get_the_post_thumbnail_url();
$list_titre = get_the_title('');
$list_content = get_the_content('');
$list_contentfilter = apply_filters('the_content',$list_content);
//$partenaire_categorie = get_the_term_list( $partenaires->ID , 'type-de-partenaire' );
//$partenaire_categorie = strip_tags( $partenaire_categorie );
//$list_categorie = get_the_terms( $partenaires->ID, 'type-de-partenaire' );

$output .= $cpt.'-'.$list_titre.'<br/>';


$output .= '<br/>';



return $output;