WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. marlonlamancio
    Member
    Posted 2 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.

    Thanks!

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 2 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
    Member
    Posted 2 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

About this Topic