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 have 2 custom post types : "industry" (page + hierarchical) and "product" (post + hierarchical). This allows me to use Industry for Product's post_parent.

On the Product manage screen, I have a custom column that displays the title of the product's post_parent, an industry. I would like to make that column sortable.

function column_orderby ( $vars )
{
    $output = array();

    switch ( $vars['orderby'] )
    {
        case 'industry':
/*
            NOT SURE WHAT TO DO HERE

            orderby post_parent's title
*/
            break;

        case 'product': // Custom column that just displays post_title differently
            $output = array(
                'orderby' => 'title'
            );
            break;
    }

    return array_merge($vars, $output);
}
add_filter('request', 'column_orderby');

I don't think I can merge any useful parameters. It has crossed my mind to use the posts_join and/or posts_where filters, but I'm not sure if this would work.

My question is, should I experiment with the hooks mentioned above or is there another way I'm not thinking of?

Cheers,

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.