function generate_404_somehow() {
global $wp_query;
$wp_query->is_404 = true;
}
add_action('wp','generate_404_somehow');
Of course, that will send all of you page to the 404 template. I don’t know what the conditions are that this should fire or not fire.
Or to be more cautious (see comments) …
function generate_404_somehow() {
global $wp_query;
$wp_query->set_404();
}
add_action('wp','generate_404_somehow');
Related Posts:
- How to force a 404 on WordPress
- Redirect Restricted Page to 404
- How to prevent automatic redirection of 404 errors and “incorrect” URLs?
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- How do I skip wordpress’s 404 handling?
- 404 redirection and Google’s index [closed]
- Redirect feed to 404 page
- Check if post is in draft or pending review?
- Why specific file directory fails to redirect but its parent folder succeeds?
- WordPress blocking/preventing viewing of .cgi file in subdirectory [closed]
- Deny access to a path (give 403 or 404 response)
- Redirect a page id url but not the page slug
- Defining a custom 404 for non-WordPress parts of site
- WordPress Auto-Redirecting on 404
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- How to redirect a wrong search on my wordpress website to the error 404 page?
- WP page 404 error only on mobile
- Force 404 redirect to home?
- How can I redirect users on the new 404 page without plugin?
- How to redirect an old page url to the homepage
- Dynamic 404 page content while still keeping 404 status code?
- Redirect to home if page doesn’t exists [duplicate]
- Redirect to parent page if child does not exist
- How to redirect non existent pages/posts in wordpress using htaccess
- How to Redirect WordPress domain.com/?anyword to 404 Page?
- How do I redirect the browser to 404 page, if no posts are found in home page
- How do i make WordPress return 404 instead of redirecting on misspelled page?
- How to redirect if 404 error in wordpress then redirect 404.php url
- Redirect to /404/
- Page editing in backend redirecting to 404 page not found with url /post.php
- How do I skip wordpress’s 404 handling?
- Subpages return 404 server error
- WordPress subfolders htaccess bypassing the root htaccess RewriteRule
- Why my htacess rewrite return 404?
- How to Redirect Url to homepage?
- Stopping media file redirects
- Forcing header cache control in 404 pages
- redirect to 404 page
- Redirect certain 404 pages to parent page
- How to redirect non-logged in users to a specific page?
- Why is WordPress redirecting from http to https on a local environment?
- How to change the default logout link on WordPress Admin
- How to redirect after login, the working way?
- How to setup 301 redirects for multiple query string URLs?
- Redirect to current page after wordpress login
- How does WordPress redirect to WooCommerce shop page? [closed]
- htaccess redirect not working
- htaccess wildcard redirect misses some URLs
- 301 Redirect Custom URL hierarchy to WordPress Posts
- Plugin Redirect After Activation
- Wp Login redirect strips parameters from url
- Mixed Content with SSL, wordpress behind a reverse proxy
- 302 redirect to signup with nginx reverse proxy
- Strange redirection issues on wordpress from ssl with padlock to ssl without padlock
- Redirect HTTP to HTTPS
- Redirect away from login page
- Redirect if $_Server[‘REQUEST_URI’] is /wp-login.php?checkemail=registered
- set up 301 redirect within wp-content/uploads/ directory of a WP site to a new image URL
- How to redirect user after login to a specific page?
- How can I redirect a URL to an anchor link while maintaining the URL?
- How to remove duplicate and unnecessary part in a url using htaccess and regex?
- Masked a external URL and redirection plugin
- Redirect outside WP after login
- Redirect non existing page to frontpage
- How do I do a redirect to WordPress permalink with post id via htaccess?
- How to prevent redirect 301
- How to redirect multiple subfolders back to root domain?
- Redirect After Login Error
- Is it possible to detect if a POST action is for a “Save Post” before the save_post action?
- Disable and Hide WP-JSON
- URL redirection
- Old missing file in wp-content/uploads/ returns a 500 error, how to catch and redirect?
- Browsers Forcing Multisite to https
- Is it possible to change redirect template through a shortcode?
- How do redirect user back to previous page when on certain pages?
- How to 301 redirect WP posts id “/c/94940894” to permalink with post name?
- Extending page urls without getting a 404
- WP 301 redirect does not work
- Remove all feeds and return custom 404 page
- Redirect Image URL to it’s parent post
- WordPress Redirect post to outside website based on useragent
- WordPress site not forcing from http to https instead getting redirected too many times
- Redirect not work
- There is 1 redirect
- Redirect to custom admin menu after plugin activation
- All new posts serving 301 redirect
- home page redirect loop after update to 4.8
- Moving site from HTTP to HTTPS
- Redirect from plugin created page
- What’s the best way to redirect to a new wordpress website?
- 301 Redirect only for posts
- How to get redirection to not redirect to 404 page?
- Custom redirects with using SQL
- Getting error when trying to redirect WP site to mobile site
- wp_login_form: Redirect to dynamic url according to username
- Hide page for user logged and redirect for profile? [duplicate]
- Redirect URL while building site
- Creating custom link that redirects to a another link
- Other pages fine but wp-admin showing ERR_TOO_MANY_REDIRECTS Error
- How to disable login and registration pages?