WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type IDs (8 posts)

  1. whoosh
    Member
    Posted 2 years ago #

    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!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  3. pedjas
    Member
    Posted 2 years ago #

    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.

  4. whoosh
    Member
    Posted 2 years ago #

    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.

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    Sorry - it's simply not an option within WordPress.

  6. pedjas
    Member
    Posted 2 years ago #

    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.

  7. whoosh
    Member
    Posted 2 years ago #

    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.

  8. pedjas
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic