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
- 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
- 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
- Relative redirects for posts, categories, products and product categories
- Display Meta Values in Custom Filter – Admin Custom Posts
- Lost draft under all posts and drafts
- 301 (static page instead latest posts)
- Simultaneous admin updates causes custom fields to not update
- Hook in to add new post link wp admin?
- Set static page/post from another blog on same network
- plugin to post from admin to flickr [closed]
- redirect to uploaded (wordpress) post after form submission from front-end
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- Retrieve only posts from a specific user in wp-admin/edit.php
- Adding an Archive button to posts page for administrators
- How do I Redirect a WordPress Page?
- Develop Admin Panel Page
- Fast publishing in wordpress
- Which file do I need to edit the All Posts page in the admin area?
- How do you search for a post or page with a certain url on the WordPress admin panel?
- How to get the old WordPress Draft Editor view back with the Word count?
- Change the color of the Password Protected Post titles
- WordPress 302 Redirect to Random Product/Post/Page
- Bolding several words at once
- 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?
- Lightbox on wordpress post page
- 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
- 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
- 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
- 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