Forums

universal permalink structure across post types (not pages) (10 posts)

  1. Rab
    Member
    Posted 11 months ago #

    Hi folks,

    I'm looking for a way to have all posts from all non-hierarchical post types use the same simple permalink structure.

    The structure I'd like to use is this:

    /%year%/%postname%-%post_id%/

    As you can see this removes the need for any post type names or taxonomy names and there's no chance of slugs clashing thanks to the post id at the end.

    Is this possible?

    Cheers,
    Robert

  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    5 bumps deleted. Please don't do that.

    You're talking Custom Post Types, I presume?

    I think you're still going to run into a postname conflict, in that if you make two posts of the same name, the second will get -2 tacked on.

    ETA - This plugin, which is no longer supported, may be what you need. http://wordpress.org/extend/plugins/custom-post-permalinks/

  3. Rab
    Member
    Posted 10 months ago #

    I think you're still going to run into a postname conflict, in that if you make two posts of the same name, the second will get -2 tacked on.

    This is why I've added -%post_id% to the end in order to avoid conflicts.

  4. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    Yeah, but that's now how WP sees it (I THINK! I could be wrong!)

    try it out. Go make two posts with the slug 'test' and I'm pretty sure it'll change it to 'test-2' on one of 'em.

  5. Rab
    Member
    Posted 10 months ago #

    I tried it out on another site I'm working on, it happily recognised the post ID was on the end of the slug and didn't add -2 to it :)

  6. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    Hey cool! That was killing me on another site. Then you should be good to go :)

  7. Rab
    Member
    Posted 10 months ago #

    Do you think it's wise to use a plugin which could break at the next update? You're not aware of any way I can achieve this within functions.php in my theme?

  8. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    You could fork the plugin. I don't know that the plugin will break (the author's really a smart fellow, even if he did stop supporting it, it's well written).

  9. Rab
    Member
    Posted 10 months ago #

    I wish I was enough of a PHP guru to fork it, plus I'm sure it's something which will end up in the core eventually. Unfortunately it's something which would be really handy right now.

    I'll give the plugin a try and report back on how I get on with it.

    Thanks for your help :)

  10. Rab
    Member
    Posted 9 months ago #

    Damnit, I went to download the plugin and it's gone :(

Reply

You must log in to post.

About this Topic