Error with 'array_merge()' when getting connections of the same post type
-
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.
Viewing 2 replies - 1 through 2 (of 2 total)
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.