WordPress.org

Forums

Posts 2 Posts
[resolved] Using 'connected_query' to filter both ends of multiple connections (2 posts)

  1. Joe Banks
    Member
    Posted 2 years ago #

    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/

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    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.

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

Tags