Title: Changing Permanent Links
Last modified: August 20, 2016

---

# Changing Permanent Links

 *  [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/)
 * I currently have my links like this /%postname%/ –
 * I’d like to change them to this /%post_id%/%postname%/ (because I read that it
   helps the site load faster).
 * Is there way to have /%postname%/ links (on other sites) automatically redirect
   to the /%post_id%/%postname%/ links?
 * Thanks in advance,
 * nando

Viewing 15 replies - 1 through 15 (of 30 total)

1 [2](https://wordpress.org/support/topic/changing-permanent-links/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/changing-permanent-links/page/2/?output_format=md)

 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078462)
 * Not really, since that’s not a ‘standard’ format that can be grep’d or regex’d
   easily.
 * Problem: Postname can be ANYTHING so while we can search for (.*), we would have
   to have a way to KNOW what Post ID == Postname, and that you can’t really do 
   outside of WP.
 * If you have a small number of posts you could manually do 301 redirects in your.
   htaccess (I did that for a site with 30 posts – not TOO horrible).
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078469)
 * i have way to many posts to do that lol
 * thanks tho… i thought there would be something i can put in the header that would
   just append the id to the url and redirect… i thought i read something like that
   some where…
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078507)
 * You know, scrap all that.
 * I use domain.com/YYYY/POSTNAME and I just went to domain.com/POSTNAME and it 
   redirected me… So maybe WordPress is bloody brilliant! Try it.
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078724)
 * just tried it, did NOT work… i was hoping tho lol
 * wow theres has to be a way, hopefully lol
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078725)
 * You could add some conditional code to your theme’s header, but it might result
   in a few redirect loops.
 * That conditional code would look something like the code posted at [http://pastebin.com/vhQ3SghQ](http://pastebin.com/vhQ3SghQ)
   I think (I haven’t tested that code, and am working from memory at the moment).
 * You would have to put that either at the very top of your 404.php template file(
   above the call to `get_header()` or at the very top of your header.php file; 
   as it uses the PHP `header()` function, which will generate an error if any code
   or text is sent to the browser beforehand.
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078726)
 * hey, thanks!!
 * i put the code above get_header{} in my 404 template but unfortunately when i
   go to post that should give me a 404 (and then redirect) i get a blank white 
   page….
 * any additional help would be greatly appreciated since i’m pretty noob at this…
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078727)
 * Curtiss, that is amazing! AWESOME!
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078728)
 * That means there’s a PHP error (probably something simple in the code I provided
   you). Do you have access to your error logs? If so, can you reload the page that
   causes the blank white screen, then check the logs and paste in the most recent
   errors?
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078729)
 * isetenu, u got it to work?
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078730)
 * heres the last minute of errors (a lot)
 * [Tue May 17 15:01:20 2011] [info] [client 168.10.192.3] (32)Broken pipe: core_ou
   
   tput_filter: writing data to the network [Tue May 17 15:01:20 2011] [error] [
   client 168.10.192.3] PHP Fatal error: Call [Tue May 17 15:01:20 2011] [info] [
   client 168.10.192.3] (32)Broken pipe: core_ou tput_filter: writing data to the
   network utput_filter: writing data to the network [Tue May 17 15:01:16 2011] [
   info] [client 64.56.91.45] (32)Broken pipe: core_out put_filter: writing data
   to the network [Tue May 17 15:01:16 2011] [error] [client 64.56.91.45] PHP Fatal
   error: Call t o a member function get() on a non-object in /usr/local/apache228/
   htdocs/wp-incl udes/cache.php on line 93 [Tue May 17 15:01:16 2011] [info] [client
   64.56.91.45] (32)Broken pipe: core_out put_filter: writing data to the network[
   Tue May 17 15:01:16 2011] [info] [client 64.56.91.45] (32)Broken pipe: core_out
   put_filter: writing data to the network [Tue May 17 15:01:16 2011] [error] [client
   64.56.91.45] PHP Fatal error: Call t o a member function get() on a non-object
   in /usr/local/apache228/htdocs/wp-incl udes/cache.php on line 93 [Tue May 17 
   15:01:17 2011] [info] [client 64.56.91.45] (32)Broken pipe: core_out put_filter:
   writing data to the network [Tue May 17 15:01:19 2011] [info] [client 168.10.192.3](
   32)Broken pipe: core_ou tput_filter: writing data to the network [Tue May 17 
   15:01:19 2011] [error] [client 168.10.192.3] PHP Fatal error: Call to a member
   function get() on a non-object in /usr/local/apache228/htdocs/wp-inc ludes/cache.
   php on line 93 [Tue May 17 15:01:19 2011] [info] [client 168.10.192.3] (32)Broken
   pipe: core_ou tput_filter: writing data to the network [Tue May 17 15:01:20 2011][
   info] [client 168.10.192.3] (32)Broken pipe: core_ou tput_filter: writing data
   to the network [Tue May 17 15:01:20 2011] [error] [client 168.10.192.3] PHP Fatal
   error: Call to a member function get() on a non-object in /usr/local/apache228/
   htdocs/wp-inc ludes/cache.php on line 93
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078731)
 * [@nando99](https://wordpress.org/support/users/nando99/) – My guess is that you
   pasted the `<?php` and `?>` tags inside of an area that’s already wrapped in `
   <?php` and `?>` tags.
 * Having two sets of `<?php` (opening) tags without a set of `?>` (closing) tags
   in between will throw an error. I just tested it briefly on one of my sites and
   I didn’t get any PHP errors, so that issue is my best guess right now.
 * Try removing the `<?php` and `?>` tags from the code I posted on Pastebin and
   see if that fixes the issue.
 * If not, try restoring your 404.php file to its original format, then copy and
   paste the whole block of code (including the opening and closing PHP tags) at
   the very top of your 404.php file (before the opening `<?php` tag in that file).
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078732)
 * You could wrap it in is_404() and put it in your header.php file too.
 * [http://codex.wordpress.org/Function_Reference/is_404](http://codex.wordpress.org/Function_Reference/is_404)
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078733)
 * this is how i have it:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078734)
 * Oooh. Just noticed what is probably causing the issue. The original code I provided
   was trying to feed an array of post objects into the `get_permalink()` function.
   Try the code at [http://pastebin.com/ku8y1LgA](http://pastebin.com/ku8y1LgA) 
   and see if that fixes the issue.
 *  Thread Starter [nando99](https://wordpress.org/support/users/nando99/)
 * (@nando99)
 * [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/#post-2078735)
 * I’m pretty sure I LOVE YOU right now… thanks!!!!!!!!!!!!!!!!!!!!!!!

Viewing 15 replies - 1 through 15 (of 30 total)

1 [2](https://wordpress.org/support/topic/changing-permanent-links/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/changing-permanent-links/page/2/?output_format=md)

The topic ‘Changing Permanent Links’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 30 replies
 * 3 participants
 * Last reply from: [nando99](https://wordpress.org/support/users/nando99/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/changing-permanent-links/page/2/#post-2078754)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
