WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Joe Banks
    Member
    Posted 1 year 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 1 year 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

About this Topic

Tags