Categories: Snippets

How to change the WordPress permalink structure to remove dates from the URLs

Switching the permalink structure from /year/month/post-slug to just /post-slug is easy by going to Settings > Permalinks and choosing “Post name”:

But you don’t want any links to your old URLs to end up generating a 404, negatively affecting SEO.  To fix this you’ll want to add in a redirect into your .htaccess file similar to:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourwebsite.com/$3

 

Recent Posts

Adding or Including custom post type to default WordPress loop

Adding or Including custom post type to default WordPress loop by altering the 'pre_get_posts' function.…

5 years ago

How to Limit or Disable WordPress Post Revisions

Limit the number of posts revisions that WordPress stores in the database. edit wp-config.php file…

5 years ago

Multisite – List Recent Posts Across an Entire Network

In Multisite, List Recent Posts Across an Entire Network by using custom query or WP_Query…

5 years ago

Disable update notification for individual plugins / All

code for the plugin file itself:- [crayon-662f1ee6ea100087016302/] I like to put this in the actual…

5 years ago

Limit character in content and title in wordpress

[crayon-662f1ee6ea26a521624903/] or with readmore [crayon-662f1ee6ea26f828721451/]  

6 years ago

Hide page visual editor if certain template is selected

[crayon-662f1ee6ea3d8089893859/]  

6 years ago