• Resolved nfq01

    (@nfq01)


    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

    (@wpallimport)

    Hi @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 ( https://www.wpallimport.com/documentation/developers/action-reference/ ) to programmatically update the duplicates when the first match is updated.

    Thread Starter nfq01

    (@nfq01)

    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

    (@wpallimport)

    Hi @nfq01,

    The ‘pmxi_saved_post’ hook would be the one to use: https://www.wpallimport.com/documentation/advanced/action-reference/#pmxi_saved_post.

    Within that hook you can get the ID via get_post_meta(), search for other posts with the same ID using get_posts() (using “meta_key” and “meta_value” in the args), and then update them using wp_set_object_terms().

    Thread Starter nfq01

    (@nfq01)

    Can premium support help with this?

    Plugin Author WP All Import

    (@wpallimport)

    Hi @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. 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

    (@nfq01)

    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

    (@nfq01)

    Like 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

    (@wpallimport)

    Hey @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

    (@wpallimport)

    Hi @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.