Posts 2 Posts
[resolved] Error with 'array_merge()' when getting connections of the same post type (3 posts)

  1. David Gard
    Posted 3 years ago #

    Hey all,

    I am trying to return connections where the Post type is the same (service), but I am getting an error -

    Warning: array_merge(): Argument #1 is not an array in /var/www/html/website/test/wp-content/plugins/posts-to-posts/core/util.php on line 84

    Other uses of the plugin are working fine, and I cannot figure out what is causing this error. Any idea what I am doing wrong?

    Here is the function that is causing the error -

    function get_service_children(){
    	/** Set the args and grab the connection posts */
    	$args = array(
    		'orderby' => 'title',
    		'order' => ASC,
    		'post_type' => POST_TYPE_SERVICE,
    		'showposts' => -1
    	$children = p2p_type('service_parents_and_children')->set_direction('to')->get_connected(get_queried_object_id(), $args);
    	$children = $children->posts;
    	return (!empty($children)) ? $children : array();

    And here is the connection being declared -

    add_action('wp_loaded', 'p2p_connection_types');
    function p2p_connection_types(){
    	if(!function_exists('p2p_register_connection_type')) :
    		'name' => 'service_parents_and_children',
    		'from' => POST_TYPE_SERVICE,
    		'to' => POST_TYPE_SERVICE,
    		'title' => array('from' => 'Parent to this Service', 'to' => 'Children of this Service')



  2. scribu
    Plugin Author

    Posted 3 years ago #

    This should be fixed in the development version (1.4.3-alpha).

  3. David Gard
    Posted 3 years ago #

    Thanks for the heads up.

    I found out that removing the post_type from the query got it working in the interim (and really post_type shouldn't matter in most Posts2Posts queries).

    I updated yesterday, so will try adding them back it.

    Thanks again for the great plugin.

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


No tags yet.