Support » Plugin: Posts 2 Posts » Error with 'array_merge()' when getting connections of the same post type

  • Resolved David Gard

    (@duck_boy)


    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')) :
    		return;
    	endif;
    
    	p2p_register_connection_type(array(
    		'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')
    
    	));
    
    }

    Thanks.

    http://wordpress.org/extend/plugins/posts-to-posts/

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

    (@scribu)

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

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Error with 'array_merge()' when getting connections of the same post type’ is closed to new replies.