[wp-hackers] Alternate paging URLs

Dan Phiffer dan at phiffer.org
Wed Mar 3 04:06:11 UTC 2010


Hi all,

I don't like the URL structure /page/2/ for two reasons:

- Its content changes, making it not very bookmark-friendly (or search results friendly)
- It contains a path that isn't valid, /page/

I'd prefer to use ?start=key, where key is a URL slug or ID number. I've worked out some SQL that I think will do what I want, but I don't know how difficult this might be to actually implement given that it deals with pretty low-level stuff.

I guess I should ask if this has come up on the list before in case there's past discussion to be consulted with. Also, I'm kind of new to the world of MySQL subselects (which my first pass solution depends on) -- are they at all efficient?

Here's the general idea:

/?start=url-slug-foo

SELECT position
FROM (
  SELECT @rownum:=@rownum+1 'position', post_name
  FROM wp_posts, (SELECT @rownum:=0) sub2
  ORDER BY post_date DESC) sub1
WHERE post_name = 'url-slug-foo'

SELECT *
FROM wp_posts
ORDER BY post_date DESC
LIMIT $position,10

Thanks,
-Dan


More information about the wp-hackers mailing list