WordPress.org

Make WordPress Core

Changeset 13315


Ignore:
Timestamp:
02/22/2010 10:54:21 PM (8 years ago)
Author:
markjaquith
Message:

Serve a real 404 for ?p=does-not-exist, ?cat=does-not-exist, etc. fixes #12250. fixes #10930.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r13194 r13315  
    462462
    463463    /**
    464      * Set the Headers for 404, if permalink is not found.
    465      *
    466      * Issue a 404 if a permalink request doesn't match any posts.  Don't issue
    467      * a 404 if one was already issued, if the request was a search, or if the
    468      * request was a regular query string request rather than a permalink
    469      * request. Issues a 200, if not 404.
     464     * Set the Headers for 404, if nothing is found for requested URL.
     465     *
     466     * Issue a 404 if a request doesn't match any posts and doesn't match
     467     * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
     468     * issued, and if the request was not a search or the homepage.
     469     *
     470     * Otherwise, issue a 200.
    470471     *
    471472     * @since 2.0.0
     
    474475        global $wp_query;
    475476
    476         if ( (0 == count($wp_query->posts)) && !is_404() && !is_robots() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
     477        if ( ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_search() && !is_home() ) {
    477478            // Don't 404 for these queries if they matched an object.
    478             if ( ( is_tag() || is_category() || is_author() ) && $wp_query->get_queried_object() ) {
     479            if ( ( is_tag() || is_category() || is_tax() || is_author() ) && $wp_query->get_queried_object() ) {
    479480                if ( !is_404() )
    480481                    status_header( 200 );
Note: See TracChangeset for help on using the changeset viewer.