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.

58 Comments

  1. Posted November 8, 2011 at 4:08 am | Permalink

    Hi Michael,

    Great plugin.

    It’s working fine for all pages and posts, except for category and sub-category urls.

    I get a 404 not found error. For example: http://www.zorba.com.co/places/medellin/accommodation

    I have my Custom Structure as: /%postname%

    I read in a previous post that one solution might be to modify the .htaccess file – however – unless i’ve gone completely mad – I don’t have such a file.

    Any thoughts much appreciated :-)

    jamie

  2. Posted November 12, 2011 at 11:25 pm | Permalink

    I have since moved to a linux server – and found my .htaccess file.

    I added the snippet of code you suggested but the problem remains.

    I’ve tried setting the Permalink structure according to 3 different variables, but as you can see no setting works 100%.

    /%category%/%postname%/ category 404 error sub-category 404 error post no problem

    %postname%/ category 404 error sub-category 404 error post no problem

    /%category%

    category no problem sub-category no problem post moves to sub category of that post and then when clicking post again nothing happens

  3. Posted November 12, 2011 at 11:31 pm | Permalink

    Really sorry, I’m posting the information again because the formatting didn’t work:

    /%category%/%postname%/ category = 404 error sub-category = 404 error post = no problem

    %postname%/ category = 404 error sub-category = 404 error post = no problem

    /%category% category = no problem sub-category = no problem post = moves to sub category of that post and then when clicking post again nothing happens

  4. Posted November 14, 2011 at 5:33 pm | Permalink

    Jamie, Zorba: There seems to be an odd issue related to WP 3.2.1 – I wonder if you might try a development version and let me know if it fixes your respective issues at all.

    You can grab it here: http://downloads.wordpress.org/plugin/custom-permalinks.zip (wait an hour two after this was posted (6PM GMT+1) to be sure it’s the lastest version there)

  5. Posted November 14, 2011 at 9:39 pm | Permalink

    Hi Michael,

    Thanks for getting back to me.

    I’ve deactivated but not deleted the previous install.

    Trying to upload the new version fails.

    Presumably, it will work if I completely delete the old version – however – if I do this – will I lose all the custom permalinks I’ve set?

    Kind regards,

    jamie

    • Posted November 14, 2011 at 9:54 pm | Permalink

      I suggest renaming the folder (say, to “custom-permalinks-disabled”), to move it out of the way, then putting the new version in its place. You won’t lose any settings – installation/removal won’t touch those.

  6. Posted November 14, 2011 at 10:17 pm | Permalink

    Hi Michael,

    Thanks.

    I’ve installed the new version – but unfortunately the problem remains.

    For example, http://www.zorba.com.co/places/medellin/nightlife

    Any ideas?

    Kind regards,

    jamie

    • Posted November 16, 2011 at 4:36 pm | Permalink

      Hey Jamie,

      I just re-read your original post, and I wasn’t quite sure about the specifics of your problem – are you saying that posts/categories that you’ve set a custom permalink on give a 404 error when you visit them, with varying effects from your WP permalink settings? You mentioned “sub-category URLs” – do you mean these are URLs for categories that you’ve manually assigned? Would you give an example of a problematic category, with the original permalink, and the custom one you’ve supplied?

  7. Posted November 16, 2011 at 4:55 pm | Permalink

    Yes, you are correct.

    When I say ‘sub-categories’ – I mean categories I have made-up and assigned to individual posts.

    If I set my wordpress permalinks as %category%/%postname% OR just %postname% then all categories and sub-categories are not accessible.

    If I set my wordpress permalinks as %category% then all categories are accessible but individual posts within those categories are not.

    Here’s an original permalink which still works if I deactivate the permalinks plugin: http://www.zorba.com.co/category/accommodation/

    Here’s the link which I like and which I’ve specified as a custom permalink – but which leads to a 404 error when I activate the plugin: http://www.zorba.com.co/places/medellin/accommodation

    • Posted November 20, 2011 at 2:34 pm | Permalink

      Hmm, I see! Well, when I get some time I’ll take a look at this (but it may be a little while before I get the chance, I’m afraid)

  8. Koji
    Posted November 29, 2011 at 12:34 am | Permalink

    I’m having a problem after upgrading to new version 0.7.8 my default permalink rule was /%postname%/. Now I have to write on the permalink field for each post as my default rule suddently stopped working, instead it shows me the default link like ?p=123.

    I’ve tried to reinstall old version, but still not working, if I disable custom permalinks the automatic permalink works.

    • Baalam
      Posted May 16, 2012 at 8:15 pm | Permalink

      I have the same problem… did you get a fix?

      Any solution for this Michael?

      Thank you,

  9. azumi_ashley
    Posted December 7, 2011 at 9:58 am | Permalink

    hi…hope somebody helps me on this. I have activated this plugin. I was wondering if I can put a space in the URL using this plugin. When I try to do that on my own, the space became a plus sign in the updated URL. Thanks in advance.

  10. henning
    Posted December 7, 2011 at 12:20 pm | Permalink

    Plugin looks pretty cool. Doesn’t seem to work with Custom taxonomies…. Or am I doing somethimg wrong?

    Cheers Henning

  11. Posted December 16, 2011 at 7:23 pm | Permalink

    What with plugin? Doesn’t work with 3.3 version?

  12. Posted December 19, 2011 at 6:08 am | Permalink

    Hi. Love your useful plug-in but I got a problem. Out of my 2k+ posts some (only some. randomly) are giving 404 error when your plugin is activated . These some posts don’t have custom permalink meta in them. After I deactivate plugin posts work fine. After I activate it back problem returns as well. Hope you can fix this. And tnx for your hard work ;)

  13. Eric TF Bat
    Posted December 28, 2011 at 10:58 am | Permalink

    Encountering an interesting bug. When I set a particular page as the static Front Page for my site, if it has a custom permalink it generates a 404 error, either as example.com/ or as example.com/my-permalink. As soon as I make some other page the Front Page instead, the /my-permalink page comes back and is fine. Removing the custom permalink and setting the un-permalinked page as the Front Page also works fine. Tracing through the code, I found a particular sequence that only runs when the original URL is an empty string; evidently that’s what’s causing the problem. Perhaps it shouldn’t be running if the URL is an empty string, only when it’s NULL, say. Actually, I might have a look and see if that makes sense, because it’s an easy fix if so. At any rate, I thought you should know.

  14. Eric TF Bat
    Posted December 28, 2011 at 11:18 am | Permalink

    … And it worked. The change is simple: in the function called custom_permalinks_request, change as follows:

    $originalUrl = ''; becomes $originalUrl = NULL; if (!$originalUrl) becomes if ($originalUrl === NULL) if ($originalUrl) becomes if ($originalUrl !== NULL)

    Note the use of the === and !== operators to do a comparison without type coercion. With that change, the thing seems to work for me. Obviously you’ll want to replicate the problem first and confirm that I haven’t proken anything, but I think it’s right.

    • Posted December 28, 2011 at 11:23 am | Permalink

      Lovely work, Eric, nicely done! I’ll roll this into an update right now. (yeah, it’s markdown, so you either need to wrap it in ‘p’ tags, or insert an empty line between) =)

  15. Eric TF Bat
    Posted December 28, 2011 at 11:18 am | Permalink

    (Damn. You need a preview function in your comment form. The three lines in the previous comment got mushed into one paragraph.)

  16. Posted January 4, 2012 at 11:30 pm | Permalink

    It looks like (in MultiSite mode) that Custom Permalinks breaks (a bit) in WordPress 3.3.1.

    When I deactivate Custom Permalinks, it works fine. But with it activated, many (not all) of my links break.

    Maybe it’s something else, but it appears to be an issue with CP. So, I would appreciate your reviewing this and just getting back to me.

    Thanks, Gary Gordon

  17. Posted January 5, 2012 at 12:33 pm | Permalink

    Hi,

    Is anyone running this plugin AND the Yoast SEO plugin as well?

    There seems to be some conflict with trailing slashes on the permalinks – at least for my installation.

    Thanks Martin

    • Posted January 6, 2012 at 12:25 am | Permalink

      Hello Michael,

      Love the plugin. I am having an interesting issue. I only need to use the custom URLs for a few old posts after migrating from one host to another to restore my Facebook “likes”.

      My issue is that for new posts, the plugin is overriding my permalink setting of /%category%/%postname%.html

      All new posts resort back to the default “?p=123”

      Only happens when I activate. As soon as I turn it off- new posts behave with my permalink settings.

      Any idea what is causing that? Any fix?

      Cheers.

  18. Posted January 6, 2012 at 12:25 am | Permalink

    Hello Michael,

    Love the plugin. I am having an interesting issue. I only need to use the custom URLs for a few old posts after migrating from one host to another to restore my Facebook “likes”.

    My issue is that for new posts, the plugin is overriding my permalink setting of /%category%/%postname%.html

    All new posts resort back to the default “?p=123″

    Only happens when I activate. As soon as I turn it off- new posts behave with my permalink settings.

    Any idea what is causing that? Any fix?

    Cheers.

  19. Jonathan Dunn
    Posted January 6, 2012 at 6:58 pm | Permalink

    This doesn’t work on multisites with wordpress 3.3.1 I get 404 errors

    • Posted January 6, 2012 at 7:14 pm | Permalink

      I said the same thing on Jan. 4th, at 11:30pm .. see above. I am hoping they might have a fix for this soon. Gary

  20. Steve
    Posted January 8, 2012 at 6:12 am | Permalink

    I think I found a bug with the latest version — 0.7.9

    On posts which are saved as a DRAFT or PENDING, when you try to preview the post after giving it a custom url they return a 404 error.

    I’m getting the same issue on all my sites using the plugin.

    Thanks,

    -Steve

    • Posted January 8, 2012 at 6:37 am | Permalink

      I downgraded back to 0.7.8 and it resolved the issue. Looks like a bug with the new .7.9 update.

      • Posted January 9, 2012 at 12:05 am | Permalink

        Same here: under WP 3.3.1, 0.7.9 would not work, but downgrading to 0.7.8 seemed to do the trick for me.

        • Tony
          Posted March 9, 2012 at 12:22 am | Permalink

          Yup, have the preview 404 bug too with Version 0.7.13 on WordPress Version 3.3.1. Would love to get this fixed soon… it’s difficult not being able to preview a post before it goes live in front of thousands of people in my case..

  21. Palpatine1976
    Posted January 11, 2012 at 1:45 pm | Permalink

    Just a +1 to MrGroove / Bill Petro –

    Confirmed incompatibility between clean install of WP 3.3.1 and Custom Permalinks 0.7.9 (but 0.7.8 works).

    Perhaps the author could please take a look? Many similar threads over on the WP CP forum too.

    Thanks!

    • Palpatine1976
      Posted January 11, 2012 at 1:53 pm | Permalink

      An easy way to show that things aren’t right in 0.7.9/3.3.1 –

      Create a Page/Post, create a Custom Permalink and UPDATE. Now edit the same Page/Post, delete the Custom Permalink custom field and click UPDATE… yet the permalink will not be deleted.

  22. Posted January 11, 2012 at 1:56 pm | Permalink

    To those having issues: In about 10 minutes from now, once the server has refreshed, try downloading and installing the development version from here (it should come up as 0.7.11).

    • Pavel
      Posted January 17, 2012 at 4:15 pm | Permalink

      Still the same issue with default permalink when adding new post. With activated plugin it looks like ?p=123, and to correct it it’s very inconvenient to type manually default wp permalink i.e. categoryname/subcat/the-big-long-postname.html for each new post or page. Let it be auto with default wp permalink settings, and only if user need – he may correct it.

      P.S. Sorry for my poor english.

  23. Posted January 18, 2012 at 5:11 pm | Permalink

    I use permalink similar to the ones used here except for the post id. Ive thought about changing it but then, going out of google’s index would mean a lot of lost trafic. That is something I cant afford

  24. Posted January 20, 2012 at 3:36 pm | Permalink

    I see in the development log of the plugin that there was an update to “Fixed issue with pending/draft posts”, but I’m still having this problem. When I preview a draft, I get error 404. When the post is published it works fine. Is this problem expected to be solved soon? Thanks a lot for this plugin.

    • Posted January 20, 2012 at 3:42 pm | Permalink

      Some people have reported that downgrading to version 0.7.8 fixed this problem for them. Not in my case. I downgraded to 0.7.8 and I continue to have previews giving 404.

  25. Brett
    Posted January 25, 2012 at 8:04 pm | Permalink

    Ok, so version 0.7.9 does not work with WP 3.3.1. I tried it on one of my pages and it didn’t work, and now that page fails to load. I tried deactivating the plugin and deleting it and I still cannot get my page to load. Any help? Where are the 301’s nested for this plugin, so that I can manually go in and delete it? I need to get my old page/url back. HELP!

    • Posted January 26, 2012 at 11:04 am | Permalink

      Hi Brett – if you’re still seeing the issue after removing/disabling Custom Permalinks, then it’s not Custom Permalinks that’s the problem; the plugin has no effect once disabled.

      • Brett
        Posted January 26, 2012 at 4:53 pm | Permalink

        Ok, I solved the problem. Not sure what was the issue. I went into my database and did a search for the problamatic url and just deleted it. Now all is working.

    • Posted January 26, 2012 at 11:05 am | Permalink

      Oh, and it definitely does work with a stock WP 3.3.1 installation – I use it on this site (this very page, in fact) with no problems.

  26. Posted January 25, 2012 at 11:46 pm | Permalink

    I thought some of those using your Custom Permalinks plugin might be interested in this information – it’s a fix I’ve discovered for the ‘redirect loop’ error ..

    I’ve been using Custom Permalinks for our website for some time with no problem at all.

    But after changing our home page from the posts page to a static page, I was struggling (as others here have done) with the fact that I was getting the ‘too many redirects’ error with Custom Permalinks activated, and our website would not load.

    I checked .htaccess, disabled other plugins (e.g the Redirection plugin I’m now using because there have been several changes to the site structure) … but still no luck and nothing I tried worked.

    Then finally I found the solution!! :)

    For the new static home page, the URL was http://bjseminars.com.au/welcome and ‘welcome’ was showing in the URL field in the admin area for that page. I simply removed the word so the URL for the page was now simply http://bjseminars.com.au .. leaving the field blank.

    Our site now loads and works as it should .. :)

    Hope this is of some help for others who experience the same problem.

    Thanks for a fantastic plugin – it’s great for keeping the URLs tidier and much simpler when there are several sub-pages on a site.

    Cheers Sue

    • Posted January 26, 2012 at 10:58 am | Permalink

      Aahhh!! Thanks so much, Sue – I’ve just had no idea why some people were seeing this problem, and you’ve put your finger right on it. It should be a pretty easy fix to ignore custom permalinks on the home page. I’ll make the change now.

    • Posted January 26, 2012 at 11:03 am | Permalink

      Oh, bugger, I still can’t replicate the issue here. Typical – works perfectly =)

  27. Eric
    Posted February 6, 2012 at 9:22 am | Permalink

    Hi,

    When adding a custom url that ends with .html, I keep getting a redirect loop.

    Is there anyway to use .html for the url without causing this?

    • Posted February 6, 2012 at 11:14 am | Permalink

      Hi Eric – it sounds like something else might be funky with your setup (perhaps something in .htaccess, or another plugin?) – it doesn’t matter what custom permalinks you set, whether they end in ‘html’ or not.

  28. Eric
    Posted February 6, 2012 at 11:35 am | Permalink

    Hi Michael,

    Thanks for your reply.

    This is a brand new blog with only 1 Page, and it is this page I tried it on.

    Latest WordPress version.

    • Posted February 6, 2012 at 11:37 am | Permalink

      Okay – first, try the development version, http://downloads.wordpress.org/plugin/custom-permalinks.zip – there’s a tweak in there for pending/draft posts that might fix your problem. I’m holding off on releasing it until I know it actually addresses the issue, so let me know if that sorts it out for you.

    • Posted February 6, 2012 at 1:34 pm | Permalink

      Ah – I may have just discovered another issue. I’ve just updated the development version (same link as above), so try that out – it’ll be an hour or so before it updates.

  29. Eric
    Posted February 6, 2012 at 4:03 pm | Permalink

    Nice, looks like it works now! :)

    • Posted February 6, 2012 at 4:59 pm | Permalink

      Ah, brilliant – it looks like there was an issue with permalinks that didn’t end in a “/”, on blogs that were hosted in a sub-directly, not the webroot.

      • Eric
        Posted February 8, 2012 at 4:32 pm | Permalink

        Hmmm, looks like if I have a url that ends with /, it displays the homepage instead.

  30. Cato
    Posted February 16, 2012 at 11:55 am | Permalink

    Hi Michael! Any idea why it doesn’t work if you have a + (plus) sign in the url? WordPress seems to rewrite the plus sign to %2B. I was hoping you might have a workaround for this because I’m working with moving an old site that needs the urls to stay the same.

    • Posted February 16, 2012 at 1:16 pm | Permalink

      Hi Cato – The plus sign is a special symbol that is one representation of a space character (the other representation of a space is %20). If you want a space, put in a space, but “+” will always be converter to a representation of the literal “+” symbol.

      • Cato
        Posted February 16, 2012 at 9:06 pm | Permalink

        Thanks for the reply! What I don’t understand though is why it’s working fine if I modify directly in the database the custom_permalink meta_key to include the plus sign? If what you say is correct than WordPress would simply return me a page not found but instead it serves me the page just fine with the plus sign in the url.

        Now the trouble is that every time when I edit that post the url goes back to include the %2B code instead of the plus sign. Clearly there is something with the way WordPress handles that url filtration but I can’t find where this conversion happens. Any ideas?

        Thank so much for even considering to read this!

        • Posted February 25, 2012 at 11:45 am | Permalink

          Sorry for the delay, Cato – If you just replace the “+” sign with a ” ” (a space) in the Custom Permalinks field, then save, it should do what you’re after. At least, it does for me – if it’s doing the wrong thing still, let me know.

      • Cato
        Posted February 17, 2012 at 9:29 am | Permalink

        Sorry Mike, it didn’t occurred to me to leave a space instead of adding the plus sign. I thought it would convert the space to %20 but in reality in coverts it to the plus sign (which, like you’ve said, is another representation of the space).

        Thank you for this great plugin!

        How would you recommend starting to develop some plugins for WordPress on my own? Besides reading the Codex of course. :) (it can get really overwhelming)