0

Is it possible to get WordPress post ID after removing that post? I have found out that I need that ID to remove the page from the site map, but I do not have the post ID, becuase I have deleted it. Sorry if that's the wrong place to ask such a question, but I am looking for the answer and I can't find it anywhere. Thank You for Your help in advance!

2
  • 3
    If you've truly deleted it, you cannot get the ID.
    – vancoder
    Mar 10 at 21:02
  • 1
    Not unless you've got a backup of your database from after the post was created but before it was deleted.
    – Pat J
    Mar 17 at 17:09

1 Answer 1

1

There's only one way I can see that you can get the ID after a post is deleted. If you're using wp_delete_post to delete posts, you add a after_delete_post action hook where you will then do the other stuff that you need to do like the remove of page from sitemap, etc. The hook has the ID and post object as it's parameter which I think will be enough for what you need for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.