Alternative 'orderby' in $args array?
-
Hello,
I have a bug in my plugin that I can’t resolve.
I need to order results by a custom post’s field ‘publisher’:global $post;
$args = array(
‘post_type’ => ‘book’,
‘post_status’ => array( ‘pending’, ‘draft’ ),
‘posts_per_page’ => 100,
‘order’ => ‘ASC’,
‘orderby’ => ‘meta_value’,
‘meta_key’ => ‘publisher’
);
query_posts( $args );It is working with one problem – If custom field ‘publisher’ does not exist in a post the post is not going to be selected. It will be missing in a result list. Even though the post is ‘pending’ or ‘draft’.
Is there a way to have alternative order clause in the $args list?
So if ‘publisher’ filed is missing for some of the posts, the results would be ordered by some other default field?
Thanks!
The topic ‘Alternative 'orderby' in $args array?’ is closed to new replies.