Title: Multiple posts with the same ID
Last modified: October 30, 2020

---

# Multiple posts with the same ID

 *  Resolved [nfq01](https://wordpress.org/support/users/nfq01/)
 * (@nfq01)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/)
 * I may have a couple of posts with the same id and am trying to update a category(
   status) for this posts. But only one of the posts with this ID is updated. Is
   it possible to somehow update all posts with a specific ID?

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

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13617943)
 * Hi [@nfq01](https://wordpress.org/support/users/nfq01/),
 * > But only one of the posts with this ID is updated. Is it possible to somehow
   > update all posts with a specific ID?
 * It should be impossible to have posts with the same ID in WordPress, so I assume
   you’re talking about an ID in a custom field, is that correct?
 * If so, I’m afraid WP All Import can only update the 1st match, so you’d need 
   to match by some other value that’s unique per-post. Or, you could write code
   that uses our API ( [http://www.wpallimport.com/documentation/developers/action-reference/](http://www.wpallimport.com/documentation/developers/action-reference/))
   to programmatically update the duplicates when the first match is updated.
 *  Thread Starter [nfq01](https://wordpress.org/support/users/nfq01/)
 * (@nfq01)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13644131)
 * Yes. I mean ID in a custom field. Please tell me which of the Hooks examples 
   closest to solving my problem?
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13645673)
 * Hi [@nfq01](https://wordpress.org/support/users/nfq01/),
 * The ‘pmxi_saved_post’ hook would be the one to use: [https://www.wpallimport.com/documentation/advanced/action-reference/#pmxi_saved_post](https://www.wpallimport.com/documentation/advanced/action-reference/#pmxi_saved_post).
 * Within that hook you can get the ID via [get_post_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/),
   search for other posts with the same ID using [get_posts()](https://developer.wordpress.org/reference/functions/get_posts/)(
   using “meta_key” and “meta_value” in the args), and then update them using [wp_set_object_terms()](https://developer.wordpress.org/reference/functions/wp_set_object_terms/).
 *  Thread Starter [nfq01](https://wordpress.org/support/users/nfq01/)
 * (@nfq01)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13667127)
 * Can premium support help with this?
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13670212)
 * Hi [@nfq01](https://wordpress.org/support/users/nfq01/),
 * Unfortunately, no.
 * In case it helps, I did find an example snippet that does something similar to
   what you’re wanting: [https://d.pr/n/8p4t0O](https://d.pr/n/8p4t0O). It updates
   the ‘_wpm_gtin_code’ custom field for all products with the same SKU (that are
   updated by import ID 7).
 *  Thread Starter [nfq01](https://wordpress.org/support/users/nfq01/)
 * (@nfq01)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13673193)
 * Thanks. I have a slightly different problem.
    There are posts with a unique key
   for which the update is matched. Updating occurs only for the first found post
   with such a key, but I need to update for everyone with the same key Thank you
   a lot!
 *  Thread Starter [nfq01](https://wordpress.org/support/users/nfq01/)
 * (@nfq01)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13673581)
 * Like [https://www.wpallimport.com/documentation/recurring/manual-record-matching/](https://www.wpallimport.com/documentation/recurring/manual-record-matching/)
   
   I chose to match by “mls_value” I have few posts with the same “mls_value” I 
   need to update category (Category name from update file) for all posts with mls_value,
   but only updates the first one found
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13689083)
 * Hey [@nfq01](https://wordpress.org/support/users/nfq01/),
 * > I need to update category (Category name from update file) for all posts with
   > mls_value, but only updates the first one found
 * WP All Import’s default behavior is to only update the first match. As explained
   above, you’ll have to write custom code to update the other matches.
 * Alternatively, you could use WP All Export to export the posts, update the file
   by adding the new categories, then use that file to update your posts and match
   by Post ID (instead of mls_value).
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13727753)
 * Hi [@nfq01](https://wordpress.org/support/users/nfq01/),
 * I’m going to go ahead and mark this as resolved since it’s been a while. Let 
   me know if you still have questions about this.
 * Anyone else, please start a new topic.

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

The topic ‘Multiple posts with the same ID’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [update](https://wordpress.org/support/topic-tag/update/)

 * 9 replies
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-posts-with-the-same-id/#post-13727753)
 * Status: resolved