Support » Plugin: Posts 2 Posts » [Plugin: Posts 2 Posts] Merging 2 connection arrays?

  • Resolved Twansparant


    Hi scribu,

    I’m struggling with this domtab menu;

    I have 2 sets of connected posts, both of them have the same connection field called ‘event-time’. What I would like to do is combine these 2 arrays into 1 and then split the posts according to the given value in the ‘event-time’ connection field into domtabs (yes I’m that guy that uses that ‘p2p_split_posts’ function)

    $c_projects = new WP_Query( array(
    	'connected_type' => 'event-project',
    	'connected_items' => get_queried_object_id()
    ) );
    $c_artists = new WP_Query( array(
    	'connected_type' => 'event-artist',
    	'connected_items' => get_queried_object_id()
    ) );
    $c_artists_projects = array_merge($c_projects, $c_artists);
    $buckets = p2p_split_posts($c_artists_projects, 'event-time' );

    The above code gives me an error saying: ‘Argument #1 is not an array’

    Can this be done? Any help is welcome.
    Thanks again for your great work by the way, loving this plugin!


Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu


    $c_artists_projects = array_merge(


    You’re brilliant! Thanks

    Hi scribu,

    I have one more thing; after succesfully splitting the connected posts into domtab groups with p2p_split_posts, I want to display connected posts from a different connection type for the post_type ‘project’ only in the main loop.

    Here’s my code:

    Everything works great, however the loop in the connected posts that also have a ‘artist-project’ connection stops after displaying:
    <h4><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>

    And the one that don’t display correctly.
    I think it might have something to do with the $post variable or resetting the query somehow?

    Any thoughts? Thanks!

    Never mind, seconds after posting I realised it was the $post variable…
    So I assigned a seperate variable to hold the original post id and used that one:
    <?php $projectid = $post->ID; ?>
    Thanks anyway!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Posts 2 Posts] Merging 2 connection arrays?’ is closed to new replies.