Creating a custom post type & specifying its POST IDs?
-
Hello, I’m making a plugin that will register a custom post type and the plugin will also regularly create, or update, posts within that custom post type.
It will integrate with a 3rd party service, via restapi.
When the plugin receives incoming data from the 3rd party it will contain a unique id already, which if its pertaining to a previously created post in my custom post type, the unique ID will remain the same as it did on its first incoming data. I want to use that unique ID to look up previously created posts… to determine if i need to create a new post, or update the existing one.
When I Google this kind of thing I am seeing “don’t change post IDs” etc, and I get that.
But given the context I’ve provided so far, would it be okay if I used the 3rd party’s unique ID and set the post id to their unique ID? They will never ever match another post in my wordpress install, they are pretty long numbers, and I may even include a prefix character to further prevent any kind of duplicate post ID issue..
I want to do this because I believe the lookup by post_id is very high performing vs. using meta tables etc.
I appreciate anyone’s time commenting on this.
- The topic ‘Creating a custom post type & specifying its POST IDs?’ is closed to new replies.