This may have a simple answer I'm not aware of, but I'm not familiar with redirects on Wordpress. Here's my question:

I had my default Posts routed to mysite.com/post-name.

I want to now route the default Posts to mysite.com/blog/post-name, which I was able to achieve through the Permalinks settings, using the custom structure /blog/%postname%/.

The problem now is that the old URLs (mysite.com/post-name) don't work (404). How do I redirect all of those old Posts to the new mysite.com/blog/post-name URL? There are a lot of posts, so I'm looking for a way to do this in bulk.

I've searched for answers, but haven't found anything satisfactory. Any help would be highly appreciated. Thanks.


There are lots of solutions to redirect from the old post URL to the new post URL.

  1. You can install a plugin "Safe Redirect Manager" and set it from the admin panel.
  2. You can write some snippet in the functions.php file as:
add_action('template_redirect', 'post_redirect_by_custom_filters');
function post_redirect_by_custom_filters() {
    global $post;
    // this array can contain category names, slugs or even IDs.
    $catArray = ['blog'];
    if (is_single($post->ID) && !has_category($catArray, $post)) {
        $new_url = "http://www.newurl.com/blog/{$post->post_name}/";  
        wp_redirect($new_url, 301);

For more details please follow the below link.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.