WordPress.org

Support

Support » Plugins and Hacks » Hacks » Custom Post Type IDs

Custom Post Type IDs

  • Hi,

    Does anybody know how can I have the IDs of the custom posts different from the IDs of other content (classical posts, pages and especially media: photos, docs).
    I don’t mind if the custom posts share the same IDs range with classical posts and pages, but I really need a way to stop it using the same IDs range as the media.

    I don’t even know, is this a wordpress or a mysql issue?!

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    @esmi

    Forum Moderator

    Both. And to the best of my knowledge, this cannot be changed. All WP objects – whether they be Posts, Pages, Revisions or Attachments – are given a MySQL auto-incremented id in strict chronological order. No exceptions.

    Using ID to distinguish type of record is generaly bad practice, thus WordPress does not do it. You should differentiate different types of posts by their type, not ID.

    If you elaborate more what exaclty you want to achieve, maybe someone could propose proper way to do it.

    Thank you Esmi and Pedjas!

    I’m thinking to create a Real Estate website and I would like each property to have a specific ID and the ID to be a part of the url.

    For example:
    http://www.example.com/id/1
    where 1 is the ID of the property.

    But the problem is that WordPress is counting an ID for each post, page, custom post and picture.
    So, for the first property I could get ID:1, but for the second property I could get ID:8, because I could have 7 pictures uploaded for the first property.

    Serious aesthetic problems could occur if I’ll have many properties and for the 100th property I could get a very ugly ID – something like 252432.

    Well, I’m sure you get the point.
    That’s why I need a way to have two IDs range: one for the custom posts (properties) and one range can be for everything else.

    esmi

    @esmi

    Forum Moderator

    Sorry – it’s simply not an option within WordPress.

    whoosh, why don’t you use permalink for that. It’s purpose is to define URL of a post, and You may freely set it up when entering post.

    WordPress fills it automaticaly using post title but you may edit and change it.

    Pedjas, I was thinking about that, but I want an automatic solution, that would create an ID for every property introduced.
    That way, I won’t have to check every time what ID is next.

    It may not sound like much, but for me is very important.

    Well, that requires plugin to set permalink according to your wishes.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Post Type IDs’ is closed to new replies.
Skip to toolbar