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 get_option function cached?
- How to include jQuery and JavaScript files correctly?
- How do I log plugin (cron) actions?
- How can I run AJAX on a button click event?
- Adding pre-publish checks with Gutenberg
- Error getting correct blog_id on MU from functions.php
- How Do I Make WordPress Run an Event Every Day?
- How do I redirect all 404 errors of a specific post type to another URL?
- How to add SQL file with PHP to WordPress database [closed]
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- Is there a faster way than wp_insert_post to add content to a blog
- How to include external library in wordpress plugin
- Delete a specific item menu when I deactivate my plugin
- Ajax in WordPress – path issue
- Platform/Website that Supports Crowd-Funded WordPress Projects? [closed]
- Get user id for delete and update selected user
- How can I call template partials inside my custom plugin
- Decrease RSS cache time in plugin?
- Add version query tag to all images
- Creating table with plugin is not working
- How to add a custom tag in contact form 7 and change the output in email?
- How to delete an user including data from custom database tables
- How to check if Woocommerce Order number equals to post ID?
- Add custom element ID depending where the widget place is, sidebar or footer
- My plugin class doesn’t work! [closed]
- 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
- is it recommended to use WP_List_Table?
- Multiple Plugin best practice in Multisite
- How to extend WooCommerce API to show bookable product availability rules?
- WordPress allows multiple users to have same email ID; and I’ve a problem with it!
- Enumerating shortcode attributes in JavaScript
- Delist entries in the_loop
- wordpress add_submenu_page adds broken link
- WP Enqueue style on all plug-in pages
- Uploaded attachment not set as featured image
- Can we use a library under MIT license in a WooCommerce plugin?
- How do I find the page/url where a search came from when using pre_get_posts filter?
- Why does comments_open() return false when publishing a scheduled post?
- Use options to control jQuery plugin
- Including template in shortcodes
- How to exclude categories from get_categories() select list inside a widget admin panel
- How to automatically activate a plugin on install
- WordPress plugin development theme issue
- Using custom IDP with WP
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- Securing custom rest API endpoints with public access from PWA
- By adding “?login – failed” code unable to access my dashboard
- jQueryUI draggable doesn’t work in WordPress plugin
- How to prevent users from deleting their accounts?
- How do I get a reference to the HTML memory buffer while the page is being constructed?
- Is it possible to restore an expired transient?
- How to Maintain url on form submit
- Experts opinions needed: How (in)secure is this approach?
- add_option_{$option} action hook not being called
- action callback, for action dispatched as reported by hook sniffer, not called
- variable created in page.php is null inside of header.php
- Access WordPress Tag Function From Modal
- how can I insert a link on login page
- Shortcode attribute “title” doesn’t appear in $atts array
- add category id to option name when adding an option on edit_category
- esc_url, esc_url_raw or sanitize_url?
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function