Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'd like to display a list of products for a certain category, sorted by the post_excerpt. The original code I used was this:

$args = array(
    'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => array( 'my-product-category' ),
            'operator' => 'IN'
        )
    ),
    'orderby' => 'post_excerpt', 
    'order' => 'ASC'
);

$loop = new WP_Query( $args );    

This displays the products, but the orderby is ignored in a taxonomy query. So I've changed the query to:

$args = array( 
            'post_type' => 'product', 
            'orderby' => 'post_excerpt', 
            'order' => 'ASC',
            'product_cat' => 'My Product Category',
            'post_status' => 'publish'
        );
$loop = new WP_Query( $args ); 

The products are displayed, but the orderby clause is still ignored.

share|improve this question
    
when you print out the $loop, this [orderby] => post_excerpt doesn't show up? –  peteroak Aug 8 '12 at 14:34

1 Answer 1

If you take a look at the WordPress Codex 'post_excerpt' is not a valid parameter for the 'orderby' parameter

For this reason it cannot be done through WP_Query(). If you don't mind, why are you trying to sort by post_excerpt in the first place?

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.