0

I've just created a draft on my blog, and it's post ID is 1. After creating another draft, the post id for this last post is 3! I was hoping to see them in sequential order, so in the future I'll have a nice auto-incremented numbering like

../archives/1  
../archives/2   

some months later...

../archives/154
../archives/155

I have no problem diving into code, but I was wondering if someone happens to know a simple solution to achieve this.

Thank you.

4
  • Seems these guys have worked out some code etc for dealing with this type of problem. Check this out and you may find your answer. - wordpress.org/support/topic/… However, I believe they are using a custom field to do the re-ordering, so I'm not sure if this will work with your permalink structure. Aug 31, 2010 at 15:48
  • Out of curiosity .. why does it matter?
    – tomjedrz
    Aug 31, 2010 at 17:12
  • Also, why would you want to do this? Numeric URLs impart very little information to the (and nothing to search engines.) Aug 31, 2010 at 21:36
  • Would be nice to count how many blog posts are there. Where can I find any proved info that the blog reader pay attention to the wordy post permanent link? I for one don't pay that much of attention. Still, I'm aware it's not search engine friendly at all.
    – rapfaria
    Sep 1, 2010 at 2:57

3 Answers 3

1

The ID of a post is not meant to be a sequence number in the sense that for post N the following post is N+1. The ID is an auto-incremented field in the posts table, which includes many things that are not published posts, e.g., drafts, pages, attachments. So there is really no way to force WordPress to assign sequential IDs in that field.

There are ways to produce a sequence number and then use it in the permalink structure, but any efficient system will involve storing the IDs in a separate location (table or option) and writing a custom rewrite plugin. That last bit is quite advanced.

It would be an intriguing problem for the experienced hacker to produce a plugin that solves this problem without significant performance degradation.

1

Pages and posts share ID's so I doubt that will work

Also - The best permalink structure for SEO is to include the postname in there

1

As the others have explained, the post ID is an auto-incremented field in the database, and so is not otherwise controllable. You obviously don't want to use this in your permalink.

Plugins and custom fields are an option, but not recommended because any "naked" number has the possibility of being misinterpreted by WordPress as a post ID or other internal number like year or date.

A simpler solution that doesn't require custom fields or plugins is to edit the post slug for each post and give it a sequential number preceded by a constant alphabetical prefix.

For example, instead of:

../archives/1  
../archives/2 
...
../archives/x

use:

../archives/p1  
../archives/p2 
...
../archives/px

Changing your permalink structure, you could even shorten this to:

../p1  
../p2 
...
../px

You can replace the "p" with whatever you want, like "day1" or "deep-thought-1".

1
  • In this case, your permalink would be /%category%/%postname%/ or /%postname%/.
    – Doug
    Aug 31, 2010 at 17:43

Your Answer

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

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