wp_insert_post wrong post type
Much like this question, I'm having trouble with wp_insert_post causing recursive post adding. I do, however, have implemented a page type check - the problem is the inserted post always gets added as the same type, no matter the type specified.
function create_auto_post($post_ID) {
if (get_post_type($post_ID) != 'manually-published') return;
$post_ID = wp_insert_post(
array(
'post_status' = 'publish',
'post_type' = 'automatically-published'
)
);
}
add_filter( 'save_post', 'create_auto_post', 1, 1);
The inserted post is of type manually-published, therefore triggering a recursive insertion of post until database time out. What am I doing wrong?
Note: I have tried using the 'publish_manually-published' action for the filter, the problem is the same - post gets added as 'manually-published' instead of 'automatically-published'.
Topic recursive wp-insert-post filters posts custom-post-types Wordpress
Category Web