I see a number of people are frustrated that WordPress can’t just have post id’s sequential. Like first post – 1, second post 2, etc,etc. Seems there are many methods to ‘force’ it to happen that way. Here is what I found, after needing to convert an XOOPS site that had WP in it, and the post Id’s weren’t sequential.
1. Install plugins wordpress-importer and wp-optimize.
2. Export your posts in WP format, so you get to know what the XML format looks like.
3. When I need to add a post, I simply ……
(a) Edit the XML file, content is not important, as once the post is imported, the post ID is ‘set’.
(b) Run wp-optimize, so that all the ‘garbage’ is removed.
(c) Import the XML file, which has the next sequential post ID specified, within it.
This works okay for me, because when I reloaded/imported all the posts from XOOPS, and ‘forced’ the post ID to be sequential, the last post id was the same number as the number of rows in the posts table.
The XML file to be imported each time is simply modified, to specify the next post ID. As long as you run wp-optimize prior to the import (wordpress-importer plugin), then the next post ID will be what you have specified in the XML file.
I notice that even if I login to WP admin, there is a row added with ‘auto draft’ in it, you can get rid of this with wp-optimize. The ID number for that auto draft was much higher than the value set in the table “wp-usermeta”, row “wp_dashboard_quick_press_last_post_id” , which did have a low value before going into the dashboard, and as soon as the auto draft is added, the value is adjusted to the autodraft ID value.
WordPress is obviously getting the next ID for the posts table, from the table “wp-options”, rather than doing a simple check on the cardinality of the posts table, and ensuring the last post id is not a higher value.
It’s not rocket science, but WP developers, why not simply have the posts table containing posts with all sequential ID’s, and let the user decide if they want ‘autosave’, ‘drafts’, or ‘revisions’, etc ??
If the user wants those “features”, simply ‘park’ them in a table called ‘drafts’ or similar. The db design could certainly do with some improvements.
- The topic ‘How to workaround autosave and revisions’ is closed to new replies.