3

I'm doing unit tests for my plugin, and in my unit test, I check some basic things such as posting a custom post type. My script can create new post, and I can retrieve the ID of the posted item (I'm redirected to an URL like http://wordpress.loc/wp-admin/post.php?post=16&action=edit&message=6, so I can deduce that the new post has the ID 16).

From this ID, I'd like to check if the post is as it should be by accessing it via URL, with something like http://wordpress.loc/?post=16, but I can't find a way to get directly to my new post using just the ID and without doing any PHP stuff.

Is that possible?

  • Use your ?your-custom-post-type=16 – Max Yudin Apr 22 '17 at 12:13
  • Nope, it returns a 404.... Maybe it would be easier to modify my function.php to do that – Alexandre Germain Apr 22 '17 at 13:23
  • 5
    OK, try ?p=16. – Max Yudin Apr 22 '17 at 13:37
  • Ok ok you got it... Why an answer to such basic question is so hard to find? Spent more than half an hour googleing around... Anyway! Thanks! – Alexandre Germain Apr 22 '17 at 15:53
  • 1
    I've read the post you linked. I'm absolutely not sorry of not being a question robot, but a fully respectful human that treats its fellow programmers like humans. People answering this question give some of their precious time, so I'm grateful of it. I'm not doing any kind of self promotion, and the greeting is just 2 words, not a full phrase of 10 words. So what's the deal with it ? Rules are good, OK, but we're still human. So unless some super admin comes to argue with me about this, I'm still grateful and I say it. – Alexandre Germain Apr 24 at 7:31
2

Post can be accessed using post id by passing it as page_id query param to index.php. e.g.

http://wordpress.loc/index.php?page_id=16

Or simply

http://wordpress.loc/?page_id=16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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