wp-posts-to-posts icon indicating copy to clipboard operation
wp-posts-to-posts copied to clipboard

query on multiple type, not same connected_items

Open vwasteels opened this issue 11 years ago • 6 comments

Hello !

Thanks for the great plugins ! I'm using this on all my projects now :)

My situation here, I'm trying to query posts filtering by multiple connection types but not with the same connected_items,

this is what I would like to do :


$query = new WP_Query(array(
    'post_type' => 'albums',
    'connected' => array(
      array(
        'connected_type'    => 'labels-albums',
        'connected_items'   => $some_label_id,
        ),
      array(
        'connected_type'    => 'artistes-albums',
        'connected_items'   => $some_artist_id,
        )
    )
));

Is there a way to achieve in a single Query ? because I need pagination and other WP filtering on it...

Thanks !!

vwasteels avatar Apr 30 '14 18:04 vwasteels

Hello, I'm still stuck on this, if anyone has an idea ...

vwasteels avatar May 20 '14 14:05 vwasteels

Anyone ?

vwasteels avatar Oct 01 '14 20:10 vwasteels

I haven't tried it but I think I saw in the docs that 'connected_type' can be an array. So instead of

'connected_type'    => 'labels-albums',

use

'connected_type'    => ['labels-albums','artistes-albums'],
'connected_items'   => [$some_label_id,$some_artist_id],

Jeff-Lewis avatar Oct 01 '14 21:10 Jeff-Lewis

Is there any update on this?

Using some something like what @Jeff-Lewis suggested doesn't seem to have much of an effect.

adrianfalleiro avatar Mar 18 '15 04:03 adrianfalleiro

I'm trying to do this too and haven't had any success so far. @Jeff-Lewis suggestion doesn't work for me either. Has anyone managed to do this?

AlchemyCompSol avatar Apr 24 '15 00:04 AlchemyCompSol

I know old, but did anyone work out this one? Thanks

ejntaylor avatar May 18 '17 20:05 ejntaylor