I'm using JSON api plugin to pull data from wordpress into an app I am making. I need a unique identifier to make sure I don't have any duplicates WHILE also using the identifier as a way to sort from newest post to oldest post. As of right now I'm confused because I pull the 10 most recent posts. I then take the ID and I attempt to reach example.com/?id=1774 but I don't get the correct post. I get a different one. I'm starting to run out of ideas?

2 Answers 2


If you look at the description for the different tables used by WordPress, the columns described as "auto_increment" will be unique.

I am not sure what you are doing though. The URL structure you are using is not one that I recognize. That is, the syntax I think you want is this:


rather than this:


?p= + a valid ID should always give you the post with the referenced ID number.

  • Hmm... I was able to get the post through api/get_post/?post_id=1774
    – EGHDK
    Jan 18, 2014 at 4:36
  • Your example in the question is example.com/?id=1774. Your example in the preceding comment looks to be passing data through an interface provided by the plugin.
    – s_ha_dum
    Jan 18, 2014 at 15:20

Yes and No.

  1. Within a blog/site id's are unique. Unless they've been tampered with (by modifying the database's AUTO_INCREMENT, or reusing old id's, which would be a bad move).

  2. Within a Wordpress Multisite Network, id's are not unique. A blog post on one site can have the same id as a blog post on another site. Probably since each site has a separate database/table. (This just happened to me.)

  3. For third-party applications (like the app you are making) you shouldn't use id as a globally unique identifier for a blog post, since if you pull data from different wordpress sites/blogs, then two blogs posts, from two different blogs, might have the same id (for the same reason as stated in point 2, above.), and you might end up getting the wrong blog post when doing a query in your own database.

Instead: Use $post->guid (guid means Global Unique Identifier, and is Wordpress' tool for this purpose), and never change it, even if the URL or the domain name of the blog changes (it's just an identifier, so it doesn't need to always match the url). NB: guid must be in lowercaps for it to work.

With the guid, you won't be able to "use the identifier as a way to sort from newest post to oldest post.", but you can pass the client_db_published_at date and use that instead (it is more reliable and detailed anyways):

// When you already have the $post in question
"blog_post[client_db_published_at]" => = get_the_time('c', $post->ID); // c  = ISO 8601 = 2004-02-12T15:19:21+00:00  . T is just a whitespace separator here. Ref: http://codex.wordpress.org/Formatting_Date_and_Time#Examples
  • NB: guid must be in lowercaps for it to work.
    – Magne
    Dec 1, 2015 at 14:35

Your Answer

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

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