WordPress.org

Make WordPress Core

Ticket #15770: 15770.diff

File 15770.diff, 756 bytes (added by benbalter, 2 years ago)

First (rough) pass at returning 404 on non-existent pages

  • class-wp.php

     
    474474        function handle_404() { 
    475475                global $wp_query; 
    476476 
    477                 if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) { 
     477                if ( ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) || ( is_paged() && ( 0 == count( $wp_query->posts ) ) ) ) {  
    478478                        // Don't 404 for these queries if they matched an object. 
    479479                        if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() && !is_paged() ) { 
    480480                                if ( !is_404() )