Blog

Custom Permalinks

200811011939.jpg

Custom Permalinks is a WordPress plugin that gives you ultimate control over your site structure.

Lay out your site the way you want it. Set the URL of any post, tag or category to anything you want. Old permalinks will redirect properly to the new address.

Support not available at this time: Unfortunately, I don’t presently have the resources to offer support for this plugin. Please direct questions to the WordPress forums

Note: This plugin is not a replacement for the inbuilt permalink settings: Custom Permalinks is designed to modify permalinks on a per-post/page/tag/category basis, not for all posts/etc at once. If you wish to alter your entire site structure, spare your sanity, and change the WordPress permalink settings instead.

Download

Download Custom Permalinks for WordPress from the Custom Permalinks WordPress plugin page.

If you like Custom Permalinks, please consider buying one of my products.

Installation

  1. Unzip the package, and upload ‘custom-permalinks’ to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Edit any post, tag or category to set a custom permalink.

Configuration

  • Open or create a post, tag, or category.
  • Under ‘Custom Permalink’, type in a URL, not including the http://domain part of the address.
  • Save

Now, the post/tag/category will be accessible at the custom address.

Incoming visitors from old links will be redirected via a 301 redirect to the new address.

See Custom Permalinks in action right here! (See the address you’re currently at?)

Notes

Interacting with other plugins which modify the URL

If you notice that some plugins, such as Keyvan Minoukadeh’s Paged Comments plugin, are not operating correctly, then ensure that your custom permalinks have a trailing slash (or not, if your standard permalinks do not have trailing slashes).

The Paged Comments plugin, and possibly others, work by adding a path component to the URL to signify state (eg. /comment-page-1), then hiding that path component from WordPress.

If you have a custom permalink with a different trailing / configuration to your normal permalinks (i.e., your custom permalink has a trailing / when others don’t, or vice versa), you will notice that these plugins no longer work, because Custom Permalinks is correcting the URL, which overwrites the plugin’s changes.

If you notice this happening, make sure you have a trailing / on your permalink, or remove the trailing slash if your standard permalinks do not have a trailing /.

Hiding the custom_permalinks custom field

A user recently asked for this; I’m not going to include it in the plugin (some people, including me, want to see this field, because we set it manually sometimes), but I’m happy to make a plugin-let to make it happen.

Here it is: hide_custom_permalink_field.php.zip

Put it in your wp-content/plugins folder and turn it on in Plugins under WP admin.

FAQ

I just get a “404 error” message when I try to visit a custom permalink

Have you configured your default permalinks to be other than the default “?p=123” style? If not, you probably haven’t got URL rewriting enabled. Either set your permalinks to one of the other options (or a custom layout), or add the following to your .htaccess file in your webroot, creating this file if necessary:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

, , . Bookmark the permalink. Both comments and trackbacks are currently closed.

30 Comments

  1. Posted November 3, 2008 at 2:07 am | Permalink

    hi. Thanks for plugin

    perfect.

    Regards

  2. Joerg
    Posted November 12, 2008 at 2:56 am | Permalink

    I try a lot but didn’t get the plugin to work with 2.6x. 404 error is always the same. htaccess and permalinks are normaly working. whats wrong?

  3. Posted November 12, 2008 at 8:14 am | Permalink

    You’ll need to give a few more details before I can help, Joerg. What permalinks are you trying to set? When do you get the 404 error?

  4. Joerg
    Posted November 12, 2008 at 10:48 am | Permalink

    I try to set the entry permalink and category permalink too. But I get an 404 error. what does the plugin do? I can’t detect any htaccess rule or so. I updated wp to 2.63 but no change will happen. You can mail me offline too. Thanks.

  5. Posted November 12, 2008 at 10:54 am | Permalink

    Hi Michael,

    I have your plugin working quite well, except for one issue — custom URL category pages don’t seem to work with pagination. Any advice?

  6. Posted November 12, 2008 at 2:54 pm | Permalink

    It’s a very useful plugin, thanks.

  7. Posted November 12, 2008 at 3:24 pm | Permalink

    Hi Krew – You’re absolutely right, I’d missed that.

    I’ve rewritten large chunks of the plugin to better-support features like pagination. Please update to 0.3 and tell me if there’s still a problem.

    Joerg: You’ll have to give me a bit more, I’m afraid. Please let me know the URL of the pages that have issues, and I’ll take a look. Additionally, what permalinks are you trying to set? By that, I mean specific permalinks. As an example, this page has a permalink of ‘wordpress/plugins/custom-permalinks/’. So, what permalinks are you trying to set? I ask because it may have an impact on operation. The plugin uses internal WordPress hooks to modify WordPress’s operation, so it doesn’t use an .htaccess.

  8. Posted November 12, 2008 at 3:40 pm | Permalink

    Thanks for such a quick response!

    Unfortunately, it doesn’t look like the category custom URLs are working at all anymore, I’m getting a 404 error.

    (This is on a dev server, otherwise I’d include a link.)

  9. Posted November 12, 2008 at 3:46 pm | Permalink

    Dammit, you’re right. There was a typo that I missed =( Update again, that should do it.

    Joerg: This might sort you out too. Please update and tell me if you still have a problem.

  10. Posted November 13, 2008 at 3:18 am | Permalink

    Your latest update seems to be working flawlessly. Thanks for all your hard work!

  11. Posted November 14, 2008 at 9:57 am | Permalink

    Hi, I’m surprised your plugin doesn’t allow modifications of Pages’ permalinks… Is this true or I missed something? Much thanks.

  12. Posted November 14, 2008 at 10:11 am | Permalink

    Hi Peter,

    You haven’t missed anything – pages aren’t yet supported, just because I personally haven’t needed that functionality, and no one’s asked for it. I’ll add it to the todo list now you’ve brought it up, though.

  13. Posted November 14, 2008 at 10:13 pm | Permalink

    Thanks Michael, since I don’t know any other possible way to get rid of parents in URLs, I’d appreciate it very much.

  14. Posted November 16, 2008 at 6:44 am | Permalink

    Any idea if this works with IIS? I couldn’t get it to work on my site – it sends me to a 404 page.

  15. Posted November 16, 2008 at 2:40 pm | Permalink

    Hi David,

    I haven’t had much exposure to IIS, and haven’t had a chance to test with it. I’m not really sure, but try opening up the php file, and pasting this near the top (just after the header comments would be fine)

    if (!isset($_SERVER['REQUEST_URI']))
    {
    $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 );
    if (isset($_SERVER['QUERY_STRING'])) $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; } }

  16. Posted November 18, 2008 at 12:47 pm | Permalink

    Thanks for the help, Michael. Unfortunately this didn’t work either. Let me know if there’s anything else you want me to try.

    By the way, you forgot the opening curly brace after the second if statement.

  17. ovidiu
    Posted November 19, 2008 at 7:45 pm | Permalink

    hi there. will this be made compatible with wp 2.7? I am currently testing the beta and it seems its not working.

  18. Posted November 19, 2008 at 7:58 pm | Permalink

    Hi! I found the BUG. If I create a post and do not publish it, but – make it a draft. When I edit after this and want to publish – it has a permalink /?p=2006

    Please fix this – so it will user the WordPress permalinks settings instead of just this. I use the permalinks li this: /archives/%post_id%

    Thank you! (Sorry for my English)

  19. Posted November 25, 2008 at 5:11 pm | Permalink

    Hi ovidiu: Yes, this will definitely support WP 2.7 – look for this in the next few weeks.

  20. Posted November 26, 2008 at 1:09 am | Permalink

    nice theme ;-)

  21. Posted November 26, 2008 at 7:54 am | Permalink

    I just want to second that request for pages support. I could sure use that right now.

    Thanks, Ian

  22. Posted November 26, 2008 at 8:16 am | Permalink

    Righto – I’ll do that today or tomorrow, as well as WP 2.7 support.

    Thanks Jensru ;)

  23. Posted November 26, 2008 at 2:22 pm | Permalink

    Thanks man, pages would solve so many problems for me I look forward to the addition.

  24. Posted November 26, 2008 at 9:46 pm | Permalink

    Thanks, perfect plugin. But i found a bug with WP 2.7 beta2 Example: Custom permalink: http://2108.lviv.ua/archives/dellorto-dhla40-service-kit.html Redirected to: http://2108.lviv.uaarchives/dellorto-dhla40-service-kit.html

    I changed the line 246 and all works fine. from: return $_CPRegisteredURL;

    to: return “/”.ltrim($_CPRegisteredURL,”/”);

  25. ovidiu
    Posted November 30, 2008 at 10:27 pm | Permalink

    hello, just wanted to ask if you could explain a little how we are supposed to best set custom permalinks, with or without trailing slash? do we use the same setting aka with/without trailing slash whether we are setting the custom permalink for a post/category or a page?

  26. Posted November 30, 2008 at 11:19 pm | Permalink

    Hi Ovidiu,

    It’s entirely up to you – if you want a trailing slash, add one. It will work either way.

    I happen to add trailing slashes, but that’s just a personal preference. If you can’t decide, perhaps keep it consistent with the rest of your site.

  27. Peter Kahoun
    Posted December 1, 2008 at 1:32 am | Permalink

    Thank you for answering my request for pages support. Unfortunatelly, it doesn’t work as expected. 1) default permalink was “lorem/ipsum” 2) i modified it to “dolorem/ipsum”, saved changes 3) tried to open preview: page was not found. Does this procedure work correctly at any of your installations? (My perm. structure: /%postname%) Thank you again.

  28. Peter Kahoun
    Posted December 1, 2008 at 1:37 am | Permalink

    Oh, and one more clarification: “lorem” is a parent page of “ipsum”.

  29. Nick
    Posted December 2, 2008 at 4:27 pm | Permalink

    Not sure if you have answered this, but is there any way for me to make a quick fix so that when I make a post it shows the time in addition to the date?

  30. Posted December 2, 2008 at 4:30 pm | Permalink

    Hi Nick,

    Are you perhaps asking a question about Elegant Grunge?

    Anyway, the answer is yes – you’ll need to edit index.php and single.php; find where the date is printed and modify the parameter; see the date documentation