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
- Can posts have parents?
- Separate Database Tables For Different Post Types
- get_children() Not Working with orderby Parameter
- How to get all posts related to particular category name?
- get comments and get posts in loop
- How to know if get_posts() failed?
- How to display posts by current user/author in a custom page template?
- How to get previous 10 days post from a specific date – WP Query
- Setting pagination for images attached to a post
- Query only Posts from Both of Two Category?
- Exporting Data from WordPress into a flat table
- Insert posts in two tables
- Instead of submiting an entire post, is there any way to submit a lite-post or a simple message?
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Can I set and show “important” post in my blog?
- setup_postdata doesn`t seem ot be working
- 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
- Split WP_POST table based on post types
- Most recent post from another database
- Automatically republish old posts
- What structure should post_content have in the database?
- How do I restart my loop with get_next_post()?
- How to modify post content?
- Insert Content In Between Post Feed
- After database migration, posts not showing up in dashboard
- Post Loop Missing Most Recent Post
- Get Posts Under Custom Taxonomy
- Transferring WordPress Database – Serialised data
- Emojis replaced by ‘?’ automatically
- Pagination with an array of post objects?
- WordPress Local And Live Site
- wp_posts table: safely remove unused columns to save database storage
- Remove a shortcode from all WordPress posts
- Posts loop displaying the same post data
- How to get posts from a current post’s month?
- How to get posts and comments amount per hour, per year and per month?
- While loop articles – if statement order
- Count number of posts of current month
- How to Get Posts, Including Private Ones?
- Random posts from a pool of posts
- Is it possible to use WP_Query to only pull posts with attachments?
- Conditional Tag for has post [closed]
- Add field to user meta table in database when link is clicked
- How to get post content from an array of ids?
- How safe is it to delete old posts edits to save database space?
- Post Filtering by GET URL parameters
- Move posts from a non-wordpress site to wordpress
- How to Assign / Move all Deleted post to a category
- Display post number by category
- Custom Articles page only showing a limited number of posts per page
- Related Posts function not working
- How to get post with slug and exclude categories
- How to select particular month post from table and update the post status using MySQL?
- Get x recent posts by author?
- Update field in database for users
- If post does not exist, do something
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Get posts from current category?
- Help on conditional statement to accompany wp_insert_post function please?
- How to add content above footer in posts from specific category
- Is it possible to modify posts table to only read for more recent ones?
- get posts, run a custom query, and join the results
- Menu Items disappearing/being empty on save or post edit
- My website is showing today’s date instead of published date since db migration to a new wordpress
- How to setup default value of post_id
- Prevent a post with a specific ID from being created
- How to mark only one post as Featured post?
- Reusing old post IDs
- Trigger on DB make problem on wordpress?
- Comments are in database, don’t show up in WordPress backend or frontend
- Is there a way to save different data when USER interacts with the same POST?
- REST API Working for GET but not for POST?
- Fill the exclude array() in get_posts()
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- Clean up customize_changeset in DB
- How to add navigation arrows to manually slide through posts?
- How do I get a certain set of posts from the database?
- How to convert return type of ‘get_posts()’ same as ‘wp_get_recent_posts()’?
- How to get all posts in gallery post format template
- How to get the current user post and it’s ID?
- I moved my site to another server, wp admin works so does the front page, but posts don’t work
- Can’t seem to replicate permalink structure for localhost development site
- When I click edit on a post, all the content disappear. Does anyone know how to fix this?
- How do I paginate posts page with $wpdb?
- How to get all post titles starting with numbers and symbols?
- Bulk Attach Or Insert Media To Post Without Opening Post Editor
- Displaying posts on Homepage
- How to get single post by one author?
- Is there a maximum amount of pages for a multi-page post?
- wordpress show category link instead of post link [closed]
- posts_per_page – Repeats only first posts ‘post__in’ array
- append $_GET parameters to post
- How to make category for word post_content
- Word count for all posts of all authors
- What effect can a large wp_post table have on overall site performance?
- Change permalinks in posts via SQL