Changing the default WordPress permalink settings
-
If I have this plugin activated, and I change the standard WordPress permalink setting from “Month and Name” to “Post Name”, will the plugin automatically redirect all of the existing month and name permalinks?
The goal is to have all future permalinks follow the post name structure, yet retain all of the existing month and name permalinks.
If the plugin can do this out of the box it’s worth the $50 in time savings alone even if I don’t need pro.
-
Hi @pkremer,
You do not need paid version to accomplish this 🙂 If you would like to make sure that the old (native) permalinks redirect to new ones, you should:
- keep the original settings (“Month and Name”) intact in “Settings -> Permalinks“
- change the permalink format for posts to “%postname%” in Permastructures section (“Tools -> Permalink Manager -> Permastructures“)
Please let me know if you need any further assistance.
Best regards,
MaciejI guess I forgot to explain one little issue – when you keep Settings->Permalinks set as “Month and Name”, and you update the posted date on a post, the permalink changes.
So if we have foo.com/2019/12/mypost, then I update it today, I end up with foo.com/2020/03/mypost
I don’t want the permalink to change when I updated the post date, which is why I wanted to change the setting in WordPress. The desired behavior is that any link that ever existed for this post still continues to work. Does the plugin function in this fashion?
Ok, I see.
Then you need to use save the old permalinks as custom permalinks. Please do the following:
- Keep the original permalinks settings intact (“Settings -> Permalinks“)
- Go to “Tools -> Permalink Manaager -> Tools -> Regenerate/reset” section and regenerate posts permalinks (this would save them as custom permalinks, so they will not be later auto-updated)
- Change the permalink format for posts to “%postname%” in Permastructures section (“Tools -> Permalink Manager -> Permastructures“)
- The new permalink format will be applied only to new posts
Best regards,
Maciej-
This reply was modified 6 years, 3 months ago by
Maciej Bis.
-
This reply was modified 6 years, 3 months ago by
Maciej Bis.
Using ‘Use original URLs as custom permalinks’ option?
Yes, exactly.
Hi @pkremer,
Did you manage to adjust the custom permalink settings? Please let me know if you need any further assistance.
Best regards,
MaciejThe regenerate option did save the original permalinks, and I made the rest of the changes as shown. However, when I update the post date on an old post to today, it breaks again by putting the new date in the permalink. Then I have to manually put the old permalink back into the redirect table. But at least that part works.
I still wonder what will happen if, now that I have the redirect table populated, I set wordpress to default to postname.
Hi @pkremer,
The custom permalinks should not be changed if you set “Auto-update the URI” mode to “No” even if you change the post date.
I am not certain what do you mean by “redirect table”.
That setting was the problem, I didn’t set the auto-update to ‘no’. Now it works. Thanks!
Hi, I got the same request, only my old posts got the format of ugly urls. May be I need a pro version?
I got old posts with the ?p=409 format, but need the future posts to be word based urls. Could you please help? Thank you.Hi @signale,
If you would like to keep old format for old posts, you do not need to use my plugin. There is a simpler way to preserve the old format and use the posts slugs in new permalinks.
- Please paste the below code snippet to functions.php file in your (child) theme directory
- Please change the date inside the code (2020-02-15) to different one. All old posts will keep the old format (“Plain”) ?p=ID, the new ones will use the new format (“Post name”).
- Please change the permalink settings in “Settings -> Permalinks” from “Plain” to “Post name”
function bis_post_permalinks($permalink, $post) { if(!empty($post->post_type) && $post->post_type == 'post') { // Old format if(strtotime($post->post_date) < strtotime('2020-02-15')) { $permalink = add_query_arg('p', $post->ID, get_home_url()); } } return $permalink; } add_filter('post_link', 'bis_post_permalinks', 9999, 2);Best regards,
Maciej-
This reply was modified 6 years, 2 months ago by
Maciej Bis.
Thanks a lot for the reply. Though I got custom permalinks for the new posts too.
The site in question is:
https://aristake.com
Here are all the posts:
https://aristake.com/?post=all#sort=newestFirst&filter=AllTopics
And posts at the bottom they got pretty urls, but redirect to ugly ones (with the changed query tag). Besides urls are not connected to the post’s names – it’s custom.
I’ve managed to achieve this pretty urls, then set redirection so that old posts redirect into /?p=304 (later will check query tag)
The client needs precise urls cause of AddThis transfer. I’ve contacted to the AddThis support and they said now the url must match 100% so to get counters as social services changed their API and now even http and https count separately.
And everything falls into its places except for the AddThis gets the url not from the actual page, but from the permalink setting! And it’s killing me as managed to configure everything so perfect.
Is there a way to give to this AddThis plugin another permalink just for the single post area? I mean only when it’s ugly permalink redirect detected then to give it another permalink. I’ve heard there are ways to have a few permalinks. Even the fact that the post opens on ugly url says it’s possible. The only thing left is to transfer the proper permalink info when it’s on the ugly version.just after formulating this I realized that I actually need a dynamic permalink :-)))
Google gave me these:
https://jasonyingling.me/dynamically-overwrite-wordpress-permalinks-with-filters/
https://stackoverflow.com/questions/51217355/custom-permalink-with-dynamic-rewrite-tags-on-a-wordpress-custom-post-type
AND
https://permalinkmanager.pro/docs/filters-hooks/how-to-programmatically-change-the-custom-permalinks/!!!
So, if I but the pro, will I be able to get this dynamic permalink thing and resolve this AddThis issue???Hi again @signale,
The solution (I mean snippet) I gave you allows you to make the post permalinks dynamic 🙂
The posts added before (15th Feb 2020 – you can change that date) will be formatted like this:
https://aristake.com/?p=35The new ones:
https://aristake.com/post/how-to-make-the-most-amount-of-tips-at-the-gigfunction bis_post_permalinks($permalink, $post) { if(!empty($post->post_type) && $post->post_type == 'post') { $home_url = trim(get_home_url(), '/'); // Old format if(strtotime($post->post_date) < strtotime('2020-02-15')) { $permalink = add_query_arg('p', $post->ID, $home_url); } // New format else { $permalink = sprintf('%s/post/%s', $home_url, $post->post_name); } } return $permalink; } add_filter('post_link', 'bis_post_permalinks', 9999, 2);Paid version will not be useful in this particular case.
Best regards,
MaciejYou’re a LifeSaver! Literally. Thank you so much.
Now, please, if I add into this:
if(!empty($post->post_type) && $post->post_type == 'post')
the is_single() condition,
if(!empty($post->post_type) && $post->post_type == 'post' && is_single())
will that mean I got pretty links on loops and the ugly ones on a signle post? Cause this is exactly what I need. My plan is to redirect from pretty to ugly(from blog to single), but having in the official permalink variable also the ugly url. This is how I intend to get the right value for AddThis share. (example http://agency.smartleads.eu/post/how-to-be-a-better-performer/ – it still shows the pretty, but when I try to share – it shows the ugly, but may be it’s only my imagination as I work on it for a while and can deceive myself)I’ve tried it and it seems to work, but may be I missed something, some exception or something?
And one more thing, do you have may be a code for changing this “?p=number” tag into this “?post=number”?
The topic ‘Changing the default WordPress permalink settings’ is closed to new replies.