If you check the line from the error notice you should find in WP 4.9.1 the usage of the function array_filter
, that need a array as parameter (see the code).
Your value inside your array for an post need an array for 'post_category'
, is currently a string.
From the source of the WP core:
* @type array $post_category Array of category names, slugs, or IDs.
* Defaults to value of the 'default_category' option.
In your source example you should change this and it should work, 'post_category' => array( $_POST['cat'] ),
.
// Add the content of the form to $post as an array
$post = array(
'post_title' => wp_strip_all_tags( $title ),
'post_content' => $description,
'post_category' => array( $_POST['cat'] ), // Usable for custom taxonomies too
'tags_input' => $tags, // Need an array
'post_status' => 'draft', // Choose: publish, preview, future, etc.
'post_type' => 'listings', // Use a custom post type if you want to
);
wp_insert_post( $post );