You may take a look at my 404 Tools plugin. I run a filter on '404_template' there. The filter function is getting the template URL as an argument, and it is still possible to send HTTP headers.
You could hook into this filter too, prepare some data you may need to print out later, change the template (eg.: to single.php) and add a do_action( 'print_my_custom_data' ); to your single.php.
Related Posts:
- Which hook should be used to add an action containing a redirect?
- Making a plugin file accessible via url rewrite?
- Custom admin_notices Messages Ignored During Redirects
- Filter to change the content of 404 page
- Pages 404 in wordpress
- Set a specific page as 404 – not found via my own plugin
- Custom rewrite rule serves content, but returns 404 error code
- How to redirect to action on custom page within admin section
- Redirect user to a particular link in 10 seconds after using wp_die
- Change template dynamically
- On cliking add new post redirect user to a custom page first
- Force HTTPS 301 redirect with hook
- Add a new confirmation page before saving
- How to redirect to login page when user not loggedin on a particular page
- If $var is empty, return 404.
- Form submission to another page returning 404 error [duplicate]
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- Custom payment method after payment user is logged out on thank you page
- Check current URL is 404 in pre_option_stylesheet filter hook
- How to Login a User inside a Plugin and Redirect to page?
- Add New Button in Admin Panel
- Redirection from a specific page for users logged in but not with membership
- Redirect WooCommerce checkout to cart
- Creating a return url for getting data from external api
- Scripts/styles not loading on cloned WP Site when logged in
- redirect_to how to make it simply work with get parameter or similar?
- Unable to link CSS file
- Any way to make Apache’s internal redirect work?
- How to load another page file of my custom plugin file
- Redirections the right way inside a plugin directory
- Plugin – Proper way to handle 404 pages?
- Custom rewrite, url path with parameters to a page
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Is get_option function cached?
- How do I log plugin (cron) actions?
- Problems after wp_set_password() containing an apostrophe
- Error getting correct blog_id on MU from functions.php
- Front-End Form Submission in Shortcode
- How do I redirect all 404 errors of a specific post type to another URL?
- Plugin Localization
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- calling jquery function on plugin page
- Is there a faster way than wp_insert_post to add content to a blog
- Ajax in WordPress – path issue
- Decrease RSS cache time in plugin?
- How to add a custom tag in contact form 7 and change the output in email?
- How can I create a plugin that changes the title color of a website?
- How to check if Woocommerce Order number equals to post ID?
- Add custom element ID depending where the widget place is, sidebar or footer
- Issue plugin commands in admin settings page
- Call PHP file within a plugin to activate function
- add_action not calling back to function
- Example Dashboard Widget, Cancel not working
- Woocommerce checkout update totals with datepicker
- add_shortcode() not working inside of function
- How to add and remove a page
- correct way to call javascript into hook function
- is it recommended to use WP_List_Table?
- Multiple Plugin best practice in Multisite
- Plugin uninstall function is not working
- Loading custom js file on the admin page through plugin
- How to prevent someone from entering strings without making it available for translation?
- I am unable to save my data from a form
- Check if post belongs to any category
- What’s wrong with my usage of add_filter
- Moving/dragging a metabox removes TinyMCE’s content
- How can I develop a plugin that generates a page dynamically
- How to redirect an old page url to the homepage
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Can calling wp_enqueue_style in wp_iframe apply the stylesheet to everything not just the iframe?
- Copied files from plugin to theme not working
- How can I allow the user to press enter without creating a new element in the editor?
- Forward an old url rewrite scheme to a new one?
- List categories with descriptions via plugin
- Will a plugin able to know is_user_logged_in?
- Widget instance options not showing correctly
- How Place a Custom Form Fields in a specific location on the User Profile Page?
- Access to the template file of a plug-in
- Can’t remove action hook on plugin class
- Bootstrap within shortcode
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- How to direct WordPress to load custom template for custom post type
- get_the_tags doesn’t works?
- Registration Forms
- Override theme’s WooCommerce file
- My plugin showing “Are you sure you want to do this” on screen with a “Argument #2 is not an array in load.php’
- Cannot save settings value
- Displaying settings information in a table
- Plugin settings not saving and 404 is generated on submit
- Refresh or redirect page after activate my plugin
- Why does is_front_page and is_home always return true for posts in wordpress? [closed]
- modify buddpress adminbar only in admin pages
- plugin backend help
- How to translate WP plugin name?
- Load images from CDN and custom features to “Add Media” dialogue
- Saving metabox updates causing fatal error
- Issue in Creating Dynamic URL in custom wordpress plugin