There are lots of solutions to redirect from the old post URL to the new post URL.
- You can install a plugin “Safe Redirect Manager” and set it from the admin panel.
- 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);
exit;
}
}
For more details please follow the below link.
https://www.ryadel.com/en/wordpress-redirect-posts-categories-tags-custom-conditions-301-302/amp/
Related Posts:
- issue in wordpress auto delete post and redirect to another 1
- How to add an admin notice upon post save/update
- Change label of title field for posts in the backend
- Exclude drafts in all() view of edit.php
- How to Arrange Posts by Size in the WordPress Dashboard?
- List latest posts in WP-Admin
- Open WordPress ‘Add New Post’ admin page with parameters set via $_GET
- using slug instead of ID in admin edit post url
- Categories box not showing on post edit pages
- Include Sticky Post in Page Posts Count?
- Display most recent post in category instead of archive?
- Make “Post published. View post” Open in a New Tab
- How to get new post URL?
- How to remove bulk edit options
- Add confirmation popup on “Move to Trash”
- Embed WordPress Admin in an iframe
- Can’t publish, edit or delete posts since Gutenberg update
- Phantom 302 status code when sending a POST requests on pages
- Send email to user that his post has been rejected
- Add filter-by-tag in the all posts admin console page
- Remove some articles from the list in WPAdmin for a user
- Redirect before post page
- How to place HTML below the title of the (custom) post overview
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- display list of posts/pages in admin edit post/page
- Custom Theme Want To Remove One Category From All Displays
- Invalid post type when click “Filter” or “Apply” button in WordPress admin Post list [closed]
- How to change the title url on the edit post screen?
- Change Order of Admin Posts Depending on Meta
- Posts are being redirected to xampp home page
- Why is WordPress redirecting users to random posts after commenting?
- Diplay comment date on WP_Post_Comments_List_Table
- Change default Posts page
- Plain permalinks not working!
- I am unable to publish/update post
- Disable inline_edit() on edit.php
- WordPress’ ALL post count info on its dashboard does not match phpMyAdmin’s ALL post count!
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Sort All Posts by Category Name in the Admin Panel?
- List latest posts with least comments in WP-Admin
- Lightbox on wordpress post page
- add_rewrite_rule and template redirect not working
- Some blog posts containing source code fail to save draft or publish
- Creating a redirect option for current page url
- How Do I Redirect WordPress Pages but not posts?
- WP_Query outputs wrong post in custom post type
- Edit post & page option does not display on latest wordpress
- Cannot create new posts or upload images using media manager
- user_has_cap filter allows “edit_others_posts” but not is not allowing updating/publishing
- ‘QTags.addButton: arg2 distorts the button rather than just shows
- Custom Fields – How to get the list of a specific active widget each time it rendered
- Every time I try accessing a post it redirects me to the feed
- My page shows some other content in WP
- the wp_post_update isn’t working all the time
- Post count doesn’t match number of posts shown in list in admin
- How to view a post from the wordpress admin screen
- Blog open in new Tab
- Redirect to custom post if custom archive page has just one result?
- Remove status ‘archived’ from the default post and page view
- Strange behaviour in WordPress admin
- How to 301 redirect from url with post id to permalink with post name (slug)?
- How to show WP admin edit page within template page/post?
- WordPress Screen Options, Help, Visual editor, Status, Visibility, Revisions, Published on and any toggled indicator don’t work for posts
- Submit New Post
- Many buttons not functioning in WordPress dashboard (as admin)
- Redirecting to “All Posts” after post publish or update
- How to redirect if is post edit or publish page?
- Set featured image on creating new post
- Blank page after changing number of post displayed in wp-admin
- how to redirect page after delete post inside a post page?
- How to sort posts in admin by name
- Is it possible to display QUICK EDIT as default for all posts in wp-admin/edit.php page?
- How can I filter the post of a CPT by taxonomy Term in admin meta-box dropdown?
- How to enable comments meta box for other author posts?
- Admin is showing all posts on page 1
- Post preview in iframe without saving the post
- I moved my site to another server, wp admin works so does the front page, but posts don’t work
- How to change the publishing date of each posts?
- Redirect posts to sub domain except pages
- Error establishing a database connection
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- Redirecting to a post based on a GET parameter and a custom field
- Post thumbnail is not shown in wp-admin
- Creating a new Sortable Column in WordPress Admin
- Enqueue CSS on custom posts’ backend area
- What does WordPress mean by they have full rights to content [closed]
- Add News Feed to bespoke website, only to one page on whole site
- Post Format Status [closed]
- Display posts with id equal to relationship value
- I cannot see the pagination in /wp-admin posts page
- Post pages are redirecting to the 404 page in wordpress
- editPost without undo entry
- Permalink issue with new blog posts > getting 301 redirect
- My website freezes for one minute every time I publish or update a post
- Post type gives 404 unless logged in
- Set Featured Image of a post
- /wp-admin/admin-ajax.php Error 500 while using divi premade layout in existing pages
- Mismatch between posts count and actual list in admin posts page
- How to restore post to pending status (no draft)
- How to add publish button in menu All Posts (Wp-Admin)