Posts 2 Posts
[resolved] Pass query parameters to get_related() (3 posts)

  1. marlonlamancio
    Posted 3 years ago #

    Hello all!

    Is there a way to pass query parameters to get_related()?

    I tried
    $respostas_relacionadas = p2p_type( 'resposta_to_desafio' )->get_related( get_queried_object(), array( 'nopaging' => true ) );
    but does not working.



  2. scribu
    Plugin Author

    Posted 3 years ago #

    get_related() is implemented using two calls to get_connected():

    public function get_related( $item, $extra_qv = array(), $output = 'raw' ) {
    	$extra_qv['fields'] = 'ids';
    	$connected = $this->get_connected( $item, $extra_qv, 'abstract' );
    	$additional_qv = array( 'p2p:exclude' => _p2p_normalize( $item ) );
    	return $this->flip_direction()->get_connected( $connected->items, $additional_qv, $output );

    As you can see, the extra query vars are passed to the first query, but not to the second, but it's pretty easy to implement your own version.

  3. marlonlamancio
    Posted 3 years ago #

    I had noticed this, but I thought there was another way.

    Thanks for your attention!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic