Skip to content

Query vars

scribu edited this page Oct 15, 2011 · 18 revisions

The P2P_Connection_Type class doesn't query the database directly. Instead, it passes custom query vars to WP_Query, which are then handled by the P2P_Query class:

'connected_query' => array(
  'posts' => 'any', post id or array of post ids
  'direction' => 'any', 'from' or 'to'
)

Shortcuts:

  • 'connected' => $posts maps to 'connected_query' => array( 'posts' => $posts, 'direction' => 'any' )
  • 'connected_to' => $posts maps to 'connected_query' => array( 'posts' => $posts, 'direction' => 'to' )
  • 'connected_from' => $posts maps to 'connected_query' => array( 'posts' => $posts, '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