WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Resync posts/categories & change autoincrement value (15 posts)

  1. GokuMew2
    Member
    Posted 8 years ago #

    Hi. At the present, I have a gap in my post ID numbers. It goes from 1-6, and then skips to 10. This is because I edited some of the post IDs and changed them to that they'd be sequential. Post ID 10 is the latest page I made. I can manually change this to 7 if I wanted to, but the next time I create another post or page, the ID will be 11 instead of 8. Is there a way I can change the autoincrement value so the next post/page will be 8 instead of 11?

    Also, because I manually changed the post IDs, I suppose the post/page links in the categories are messed up. Is there a way to resync them?

    Thanks.

    PS When you use the search function in WordPress, does it only look for posts or does it display page results as well?

  2. niziol
    Member
    Posted 8 years ago #

    Easy answer first: I use the Search Pages Plug-in, it works great.

    It is usually strongly advised against editing the database manually. The post ID's are auto increment values from MySQL, they are not generated by WordPress. It makes no difference what the post numbers are, so I don't see any reason you'd need to change them. I really have no idea how you'd reset it, but I imagine it would involve backing the DB up and restoring it with certain parameters (ie: add auto increment) missing in the SQL. This is just a vague idea, I highly recommend you don't do it!

    Why do you need to change the numbers?

  3. GokuMew2
    Member
    Posted 8 years ago #

    I change the numbers because I'm the kind of person who is bothered by gaps and stuff. I like things in the right order, etc. 1, 2, 3, 4, 5, 6, 7.... Yeah.

    There is no way to change the autoincrement value in MySQL? I would imagine the info of what the current number is stored somewhere within the database but I can't find it.

  4. niziol
    Member
    Posted 8 years ago #

    It must be stored somewhere, I'm not sure where or how though. My knowledge of MySQL is limited, so I'm afraid I can't be of much more help than that.

    I'm also one of those very picky people, so I understand the obession that comes from things not being the way I like! Maybe try Using_Permalinks instead?

    Good luck,
    Michael.

  5. vkaryl
    Member
    Posted 8 years ago #

    Well, yeah.... you can go dick around in the database and tweak the autoincrements. They're in the relevant tables, you access the "structure" to tweak it I think.

    MAKE BACKUP DUMPS OF THE DATABASE - several! If you screw around in the database without backups and you terminally terminate your database, I will be sorry for you but do NOT try to blame it on me....

  6. GokuMew2
    Member
    Posted 8 years ago #

    Oh, yeah, I do use PermaLinks. So really.... Anyone who's visiting the site wouldn't know that the post IDs have a gap, but /I/ know, so... ^^;;;; I guess I'll just have to let it be.

    If I do decide to poke around in the database, I will definitely make a backup before I do anything. By the way, does anything get affected if I change the post IDs? Like will there be broken links or anything? The only things I have right now are the default post (post ID 1; won't be changed) and some pages.

  7. vkaryl
    Member
    Posted 8 years ago #

    I couldn't tell you that positively, never having messed with it myself, but my best guess would be "yes".

  8. GokuMew2
    Member
    Posted 8 years ago #

    D'oh!

  9. Kafkaesqui

    Posted 8 years ago #

    Resetting auto-increment value for the post table:

    ALTER TABLE wp_posts AUTO_INCREMENT=X;

    Change wp_posts to correct table name if not using the default prefix (wp_). Change X to the value you want to set the next increment value to.

    I've done it for a few folks.

  10. Chris_K
    Member
    Posted 8 years ago #

    Back to the OP, if you change a posts ID, you'll need to change it wp_post2cat as well or you'll lose the category(categories) that you had put on the post.

  11. GokuMew2
    Member
    Posted 8 years ago #

    Thanks! I will try this out.

  12. GokuMew2
    Member
    Posted 8 years ago #

    Sorry, one more thing. What is "rel_id" in the wp_post2cat table of the database? Should this match the post_id? I have 7 posts/pages yet in the wp_post2cat table, I see 8 items. Am I missing something?

    Thanks.

  13. Chris_K
    Member
    Posted 8 years ago #

    Rel_ID is just an auto_inc key on this particular join table. It doesn't really mean anything.

    Remember that a post can have multiple categories, so seeing more rows in wp_post2cat than in wp_posts isn't too worrisome. If a post has 2 categories, it'll have have 2 rows here -- one for each.

  14. GokuMew2
    Member
    Posted 8 years ago #

    I see. All my posts/pages are in only one category as far as I know though... Ah well, I don't suppose it matters too much.

    Thanks for your help everyone!

  15. ia
    Member
    Posted 7 years ago #

    I change the numbers because I'm the kind of person who is bothered by gaps and stuff. I like things in the right order, etc. 1, 2, 3, 4, 5, 6, 7.... Yeah.

    Oh yes. I am this person too! Thanks guys, I managed to edit the auto-increment value by choosing the Operations tab in phpMyAdmin and then editing the auto-increment value. I think my WordPress categories are looking good far. But I better not edit the post IDs; that'd be scarier. :D

    Now if only I could figure out why the category count of a certain category is incorrect.

Topic Closed

This topic has been closed to new replies.

About this Topic