Title: [Plugin: Duplicate Post] array_diff() problem
Last modified: August 20, 2016

---

# [Plugin: Duplicate Post] array_diff() problem

 *  Resolved [itsmeka](https://wordpress.org/support/users/itsmeka/)
 * (@itsmeka)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/)
 * I am using WordPress Version **3.3.1** and duplicate post version **2.2**. When
   i click to clone or new draft of main post, it duplicate the post successfully
   but showing following message:
 * Warning: array_diff() [function.array-diff]: Argument #1 is not an array wp-content\
   plugins\duplicate-post\duplicate-post-admin.php on line 227
    Warning: Invalid
   argument supplied for foreach() in wp-content\plugins\duplicate-post\duplicate-
   post-admin.php on line 229 Warning: Cannot modify header information – headers
   already sent by (output started at wp-content\plugins\duplicate-post\duplicate-
   post-admin.php:227) in wp-includes\pluggable.php on line 866
 * [http://wordpress.org/extend/plugins/duplicate-post/](http://wordpress.org/extend/plugins/duplicate-post/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [itsmeka](https://wordpress.org/support/users/itsmeka/)
 * (@itsmeka)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632116)
 * Problem is solved. 🙂
    i have changed following code in duplicate-post-admin.
   php at line 278:
 *     ```
       if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
       	do_action( 'dp_duplicate_page', $new_post_id, $post );
       	else
       	do_action( 'dp_duplicate_post', $new_post_id, $post );
       ```
   
 * to
 *     ```
       if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
       	do_action( 'dp_duplicate_page', $new_id, $post );
       else
       	do_action( 'dp_duplicate_post', $new_id, $post );
       ```
   
 *  Plugin Author [Enrico Battocchi](https://wordpress.org/support/users/lopo/)
 * (@lopo)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632185)
 * Hi,
    thank you for reporting the issue.
 * Your workaround isn’t exactly right, there is no $new_id in that function, so
   probably it simply prevents actions to be called.
 * This means that custom fields will never be copied.
 * You should try to change lines 224-225 from
 *     ```
       $post_meta_keys = get_post_custom_keys($post->ID);
       $meta_blacklist = explode(",",get_option('duplicate_post_blacklist'));
       ```
   
 * to
 *     ```
       $post_meta_keys = get_post_custom_keys($post->ID);
       if (empty($post_meta_keys)) return;
       $meta_blacklist = explode(",",get_option('duplicate_post_blacklist'));
       ```
   
 * I hope this works.
 * I’ll make sure to fix the issue in the next version.
    Thank you!
 *  Thread Starter [itsmeka](https://wordpress.org/support/users/itsmeka/)
 * (@itsmeka)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632259)
 * I did as you said. Now it is working fine but it **does not copy** categories,
   tag and custom fields. After cloning the post, it takes the default categories(
   Uncategorized), tags(No Tags). Please advice.
 * Thank you in advance.
 *  Thread Starter [itsmeka](https://wordpress.org/support/users/itsmeka/)
 * (@itsmeka)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632279)
 * Hi logo,
    Sorry, i made some stupid wrong when i edited. Your plugins is great
   and working great. Thanks for your great work and reply.
 *  Plugin Author [Enrico Battocchi](https://wordpress.org/support/users/lopo/)
 * (@lopo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632370)
 * Hi,
    version 2.3 (out now) includes the fix for this bug.

Viewing 5 replies - 1 through 5 (of 5 total)

 The topic ‘[Plugin: Duplicate Post] array_diff() problem’ is closed to new replies.

 * ![](https://ps.w.org/duplicate-post/assets/icon-256x256.png?rev=3581701)
 * [Yoast Duplicate Post](https://wordpress.org/plugins/duplicate-post/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duplicate-post/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duplicate-post/)
 * [Active Topics](https://wordpress.org/support/plugin/duplicate-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duplicate-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duplicate-post/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Enrico Battocchi](https://wordpress.org/support/users/lopo/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-duplicate-post-array_diff-problem/#post-2632370)
 * Status: resolved