There is a dedicated method for it WP_Query->set_404()
. From quick search through code it can be set in WP_Query->parse_query()
or WP->handle_404()
(note WP
, not WP_Query
!).
But it can (and sometimes does) get set on query externally, for example by plugin that needs to invalidate specific resource.
Related Posts:
- Why is the loop not empty on some 404s?
- How to trigger 404 for custom query var?
- Pagination shows 404 after a certain number of pages
- Pagination causes error 404 when used with front-page.php
- WP-PageNavi gives me a 404 when using WP Query
- Intentionally exceed max_num_pages on main query without getting 404?
- Custom pagination with WP_Query generating 404 error
- if/else on custom query gives 200 OK when condition not met?
- Have functions work outside the loop with 404 override
- How to return a 404 when custom query matches nothing?
- paged variable not working for category/custom post archive
- Issue with front page navigation after upgrading to 3.4
- Show a 404 error page if Public query variable’s value doesn’t exist?
- How to use if($wp_query->query_vars[‘name’] == ‘pagethatdontexist’) without getting a 404? How to suppress 404
- Custom Taxonomy Breaks Pages
- Reciving Error 404 blog/page/2/
- Show a message if there are no active posts in category
- Pagination with Custom Post Type not working on index.php: I get a 404
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- PHP memory friendly alternative to get_posts()
- Sorting posts by custom date fields (non standard date format)
- How to filter sql only for a specific post type
- Loop with break in the middle
- What should I use, get_posts or wp_query for less CPU load?
- How should I use posts_where to change meta_value from a string to integer?
- Reduce Database Queries in Code [duplicate]
- meta_query with array as value
- Sort in WP_Query(), not filter? Is it possible?
- Determine WP_Query parameters from URL
- wordpress query in header won’t reset and corrupts other loops
- How add a custom posttype name using ACF field to a query post array
- Php Trying to get property ‘ID’ of non-object
- More than 1 Year Date Query
- Is it possible to dynamically get queried term AND taxonomy?
- posts_per_page not working
- Pull post meta with post_query?
- How do I force WP_query to fetch fresh, non-cached results?
- Complex WP_Query (two post types and multiple operators)
- Five posts from a category in footer
- Remove category from query (show all posts in archive.php) pre_get_posts()
- How to Union two different conditions in one WP_Query
- Display filtered results into custom page
- WooCommerce – get product sub categories
- Order by empty custom field
- WP_Delete_user link creation
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to pass orderby params to $wpdb->prepare()?
- how update data through ajax and jquery
- WP_Query arguments relation shows AND instead of OR
- Combine results of multiple WP_Query to resemble single WP_Query
- Using WP_Query() in Magento shows error
- For what queries is conditional tags informative?
- Utilising an existing page while using the “s” query parameter
- posts archive page – closing WP_Query loop correctly [closed]
- AJAX Breaking Offset Argument In WP Query
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Pagination in html table is not working
- Nested array issue in meta_query
- WP_query problem -spurious results
- Avoid duplicate while merging two query post
- Query Not working as expected
- How to create single page site in WordPress
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- Execute PHP function inside the admin area
- Populate select list with meta values from all posts of a Custom Post Type
- tax_query not working on custom post type
- WordPress Meta Query Null Values Order
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- WP Query and multiple queries
- I need query_posts() to order results first by a meta value and then by post ID
- Custom category page with taxonomy filters
- How do i query woocommerce booking post type on init action?
- make query more simplest and in one query
- How to display post based on which is clicked
- date_query problem
- WP_Query Not Working with Variable
- WP_Query doesn’t return some child pages even though the database shows them
- How to allow Readers to Select Post Order?
- Random posts in WP_Query when searching by tag
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- Pagination returns 404 after page 20
- 423 queries in 6.098 seconds
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- (How) Can I use ‘wild cards’ on the left hand side of an array argument?
- ‘s’ term in WP_Query extended class causes huge memory leak (268MB)
- Compare meta key separation
- Combine privileged users array with my current query
- Get posts from similar time as current post
- Query posts filter not working
- meta_query dates from an array
- Creating array to compare custom field values
- WordPress Query Default Order if Meta Values Same?
- WP_Query do not include posts with a certain value in a custom field –
- Having trouble using this post category query on multiple pages?
- Remove 5 latest posts from the loop
- Exclude post formats in custom loop
- WordPress WP_User_Query ignores the `meta_query` when called from an Ajax function
- Unexpected results custom wp_query and $the_query->request;
- Simple Apex Charts with jQuery not working