Make WordPress Core

Changeset 28612


Ignore:
Timestamp:
05/29/2014 05:47:35 AM (10 years ago)
Author:
wonderboymusic
Message:

When parsing the main query, if s is set to empty: ?s= and $this->is_main_query() && array_key_exists( 's', $this->query ) - kill the query instead of loading the homepage. This will load the search page with no results.

Fixes #11330.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r28605 r28612  
    15111511            $this->is_single = false;
    15121512        } else {
     1513
    15131514        // Look for archive queries. Dates, categories, authors, search, post type archives.
    1514 
    1515             if ( !empty($qv['s']) ) {
     1515            if ( ! empty( $qv['s'] ) || ( $this->is_main_query() && array_key_exists( 's', $this->query ) ) )
    15161516                $this->is_search = true;
    1517             }
    15181517
    15191518            if ( '' !== $qv['second'] ) {
     
    22622261            }
    22632262        }
     2263
     2264        if ( $this->is_search ) {
     2265            $search = 'AND 0';
     2266        }
     2267
    22642268        if ( $this->is_feed ) {
    22652269            // This overrides posts_per_page.
     
    28772881
    28782882        // Comments feeds
    2879         if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) {
     2883        if ( $this->is_comment_feed && ( $this->is_archive || ( $this->is_search && ! empty( $q['s'] ) ) || !$this->is_singular ) ) {
    28802884            if ( $this->is_archive || $this->is_search ) {
    28812885                $cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join ";
Note: See TracChangeset for help on using the changeset viewer.