public function get_p2p_id($from, $to)
 {
     return _p2p_first($this->get_connections(array('from' => $from, 'to' => $to, 'fields' => 'p2p_id')));
 }
Пример #2
0
 /**
  * Get another post in an ordered connection.
  *
  * @param int The first end of the connection.
  * @param int The second end of the connection.
  * @param int The position relative to the first parameter
  *
  * @return bool|object False on failure, post object on success
  */
 public function get_adjacent($from, $to, $which)
 {
     // The direction needs to be based on the second parameter,
     // so that it's consistent with $this->connect( $from, $to ) etc.
     $directed = $this->find_direction($to);
     if (!$directed) {
         return false;
     }
     $key = $directed->get_orderby_key();
     if (!$key) {
         return false;
     }
     $p2p_id = $directed->get_p2p_id($to, $from);
     if (!$p2p_id) {
         return false;
     }
     $order = (int) p2p_get_meta($p2p_id, $key, true);
     $adjacent = $directed->get_connected($to, array('connected_meta' => array(array('key' => $directed->get_orderby_key(), 'value' => $order + $which))), 'abstract');
     return _p2p_first($adjacent->items);
 }