I don’t believe order_clause
is an acceptable orderby parameter. According to the documentation you will need to add a meta_key
to your query if you want to orderby
a meta_value
.
I have amended your query to display attorney posts where the custom field key Last name is present regardless of the custom field value. orderby
is set to meta_value
which refers to the meta_key
which has been set to Last name.
$connected = new WP_Query(
array(
'connected_type' => 'posts_to_pages',
'connected_items' => get_queried_object(),
'nopaging' => true,
'post_type' => 'attorney',
'attorney_category'=> 'partner',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'meta_key' => 'Last name',
'orderby' => 'meta_value title',
'order' => 'ASC',
)
);
Presuming your custom field is actually called Last name this query should work.
You could add a second orderby
parameter such as title
as a fallback:
'orderby' => 'meta_value title'