Possibly the place to do this would be in the 404.php file of your theme. If there isn’t one, create one and WordPress will pick up. Note: if you want to return “non-404” content from this file you will probably need to clear the headers and set the status to 200.
I’ve done something very similar on other systems and it works fine if you take care to return the correct headers.
One word of warning though: you might want to minimise the amount of processing that happens on the this page as otherwise you might end up impacting site performance if you start lots of processing on every single 404.
Related Posts:
- Get Posts Under Custom Taxonomy
- When is the ‘post_content_filtered’ column in database cleared by WordPress?
- Can posts have parents?
- How to show related posts by category
- Separate Database Tables For Different Post Types
- get_children() Not Working with orderby Parameter
- How to get all posts related to particular category name?
- How can I safely increase the character limit for post passwords?
- How to Group Posts by the First Letter or Number?
- Restore contents of deleted user
- How to display posts by current user/author in a custom page template?
- Show the title of the latest post by author
- Setting pagination for images attached to a post
- Query only Posts from Both of Two Category?
- Custom Taxonomies Incorrectly Counting Revisions?
- WordPress get posts by date without query_posts
- database columns: post_title vs post_name
- Exporting Data from WordPress into a flat table
- Importing New Posts from Live Site into Local Dev Site
- Posts are not showing up on particular category
- get selected post using $_GET
- Manually removing revision post types
- setup_postdata doesn`t seem ot be working
- How much of my site can I recover from public_html?
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- How do I find which articles are missing a featured image in The WordPress database?
- Get Posts via Taxonomy Term Name with Space
- Get specific posts by ID in wordpress
- Automatically republish old posts
- Multiples Empty Posts were created and cannot delete them
- get_next_post() and get_previous_post() return wrong posts
- Get posts by name and taxonomy term
- Inserting custom data to the_post() during loop
- Get mixed category random posts
- WordPress not opening posts with only numbers if permalink is post_name
- Extracting post categories
- Limit popular posts by days
- How to modify post content?
- get_the_content(“more…”) returns full text
- After database migration, posts not showing up in dashboard
- Post Loop Missing Most Recent Post
- Transferring WordPress Database – Serialised data
- Emojis replaced by ‘?’ automatically
- WordPress Local And Live Site
- Copy post to separate database with “add_action(….)”
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- Anyone know why wordpress converts some html entities to their numeric equivalents?
- Remove a shortcode from all WordPress posts
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Posts loop displaying the same post data
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- Delete all drafts?
- Is it possible to use WP_Query to only pull posts with attachments?
- Get posts and include taxonomy term
- Add field to user meta table in database when link is clicked
- How to get post content from an array of ids?
- Display Posts with template on a Page
- Number of displayed posts
- How safe is it to delete old posts edits to save database space?
- Delete post revisions only for a single post
- wp_posts table extremely large
- How to Assign / Move all Deleted post to a category
- How to give classname to post if post has no content?
- Saving Post Data in Another Database
- Custom Articles page only showing a limited number of posts per page
- Restore woocommerce orders
- get_posts not pulling the correct number of posts
- Get x recent posts by author?
- List latest posts with least comments in WP-Admin
- Import custom database into wp and keep the post id
- Moved to a new server, backup was a day old and missing 3 posts, anyway to recover them from old host?
- Help on conditional statement to accompany wp_insert_post function please?
- How can I globally italicize list of texts in the UI database or Posts? [closed]
- How to show multiple posts thumbnail, title and date in widget
- I need to create “View Profile” and “Edit Profile” links by incorporating the Post Title/ID, but can’t seem to manage it
- Show only posts with titles/permalinks that do not contain certain words
- How to merge the content of posts that have the same title?
- How to add first 3-4 post tags on WordPress Post Title
- Menu Items disappearing/being empty on save or post edit
- Prevent a post with a specific ID from being created
- get_next_post() not working with future post status
- Extracting the permalink from a post instance
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- how i show manual data in a post
- WP_Query to get posts in a specific tag or has post_format
- How to Get Position of a Post from a category and tag
- SQL trigger failes with post_content
- Any difference betweenn posts and pages for one page?
- get backup file from wordpress database in x days
- Converting Posts to Pages
- How to change the publishing date of each posts?
- Given two custom post types: Automatically add meta fields from one custom post type to another
- Displaying posts on Homepage
- Word count for all posts of all authors
- View post with specific category id and name which I selected in the backend (drop-down option)
- Change permalinks in posts via SQL
- Is it safe to totally unregister the default “post” Post Type
- How to get a list of all posts and their categories?
- How to manually delete post from database without causing conflicts?