• Good Morning,

    I think this is impossible but to be sure.

    From an external service, using the REST API, the WP post will be created, using the POST method. The client wants the ID that they add in the JSON to be the ID that the post has inside the WP.

    Come on, they want the ID of their database to match that of WP. I have already indicated to you that this is impossible.

    Is it correct or is there some way to make this possible?

    If I add that external ID to a meta, could I use it to do a GET or a DELETE on that post?

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Probably not totally impossible, but definitely not worth trying to do. Think about the order in which things happen, the fact that all attachments, menus, custom CSS are also entries in the post table, and consider that not even the importer tries to match the post ID to what it was before. There is too much chance of collision.

    But your idea to put it in the meta field is solid. That is what the importer does.

    Kristina

    (@kristinaplauche)

    Automattic Happiness Engineer

    Hi there!
    It is possible to change the post ID. You can change it manually in the database, so there is probably a way to do it with code too, but there is nothing built in to do that because it is not recommended and highly discouraged. The post ID is the primary key of that database table. It auto-increments and it must be unique. So changing it will likely cause unforeseen problems at some point.

    Hopefully you can persuade your client to use the name of the post or something other than the ID. ?? I hope that helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘REST API – create post with ID external’ is closed to new replies.