WordPress.org

Ready to get started?Download WordPress

Forums

Permalinks & wp_posts problem (3 posts)

  1. NicotineLL
    Member
    Posted 1 year ago #

    Hello guys,

    I'm developing a new website, but I can't quite figure out a solution to my permalinks problem.

    My main website is http://w3spine.com, I'm sending posts to my second WP http://w3lol.com and I want posts permalinks to be like so http://w3lol.com/138581

    The problem is that I cannot use post ID since there are a whole bunch of other stuff that are stored in wp_posts and the IDs skip some numbers (ex. first is 50 next is 54 (1 post, 2 revisions and 1 attachment), 58, 62, etc) and I need the urls to be in order -> 50, 51, 52, 53, etc.

    The easiest way here is to use post slug as a permalink, but this will be problematic to regular users who have to skip a lot of images just to find the ones they haven't seen yet.

    Any solution will do, I don't mind hardcoding.

  2. bcworkz
    Member
    Posted 1 year ago #

    I don't see the problem with slug permalinks. If the first image is the last one added, and they are chronological, as regular user, I'll just arrow back through the images until things look familiar. Pretty much the way any blog works. Why confuse things?

    To answer your question, you could create a equivalence table with a unique 'lol' index id paired with the actual post id. Any post identified as being part of this collection gets it's id added to the next available index number. Thus the 'lol' id will always be sequential with no gaps, assuming you never delete anything. If you delete things, you'll need to invoke some sort of garbage collection scheme to fill the gaps.

  3. NicotineLL
    Member
    Posted 1 year ago #

    I managed to do it!

    First off, it was pointed out to me that if I leave posts with numeric permalinks they will eventually conflict with years and other slugs. This is why I added additional "i" in front of the numbers.

    My solution was to edit the Social Network Auto Poster plugin's WP option to send slugs as well (it is not set by default). I added an entry in wp_options that holds the number of posts sent via this plugin WP option, which if the post is successfully transfered is incremented by 1.

    Now the posts slugs are build like this: i1, i2, i3, etc.

    I think it's looking good and I hope I didn't miss anything that might result if future problems...

Topic Closed

This topic has been closed to new replies.

About this Topic