Skip to content

Query vars

scribu edited this page Oct 2, 2014 · 18 revisions

Here is a list of all the arguments that you can pass to WP_Query or to get_users(), to get a list of connected items:

'connected_type'

This can be the name of one or more connection types:

  • 'connected_type' => 'posts_to_pages'
  • 'connected_type' => array( 'posts_to_pages', 'pages_to_pages' )

'connected_items'

This can be one or more object IDs or full object instances, or 'any':

  • 'connected_items' => $post
  • 'connected_items' => array( $post_1, $post_2, ... )
  • 'connected_items' => 'any'

'connected_direction'

Optional, inferred from 'connected_type' + 'connected_items'.

  • 'connected_direction' => 'from'
  • 'connected_direction' => 'to'
  • 'connected_direction' => 'any'

Shortcuts:

There are a few query vars that expand to the more specific query vars above:

  • 'connected' => $posts maps to 'connected_items' => $posts, 'connected_direction' => 'any'
  • 'connected_to' => $posts maps to 'connected_items' => $posts, 'connected_direction' => 'to'
  • 'connected_from' => $posts maps to 'connected_items' => $posts, 'connected_direction' => 'from'
'connected_meta' => array(
  $meta_key => $meta_value
)

or

'connected_meta' => array(
  array(
    'key' => $meta_key,
    'value' => $meta_value,
    'compare' => '<'
  )
)

The second syntax is the same as for 'meta_query': http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

'connected_orderby' => $meta_key
'connected_order' => 'asc' or 'desc'
'connected_order_num' => true or false

... where $meta_key is a connection custom field.

When the connection type has 'sortable' => true, the order arguments are automatically set.