WordPress.org

Support

Support » Plugins and Hacks » Posts 2 Posts » [Resolved] Using 'connected_query' to filter both ends of multiple connections

[Resolved] Using 'connected_query' to filter both ends of multiple connections

  • Joe Banks

    @joebanks10

    Hi Sribu,

    The new ‘connected_query’ variable has been very useful. I’m currently using it to filter both ends of a connection, but is there a way to filter both ends of multiple connections? For instance, if I had pages connected to posts and a custom post type, it would be nice if we could do something like this:

    $pages = new WP_Query( array(
            'post_type' => 'page',
            'connected_query' => array(
                array(
                    'connected_type' => 'pages_to_posts',
                    'connected_to' => 'any',
                    'category_name' => 'tutorials',
                ),
                array(
                    'connected_type' => 'pages_to_customtype',
                    'connected_to' => 'any',
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'people',
                            'field' => 'slug',
                            'terms' => 'bob'
                        )
                    )
                )
            ),
            'nopaging' => true
        ) );

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

Viewing 1 replies (of 1 total)
  • Plugin Author scribu

    @scribu

    There is no way to do that and there probably never will be, since the query is complex enough as it is.

    You can just do multiple queries and then use array_intersect( $query1->posts, $query2->posts ) to find the posts that match all criteria.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Using 'connected_query' to filter both ends of multiple connections’ is closed to new replies.
Skip to toolbar