Making WordPress.org

Changeset 9000


Ignore:
Timestamp:
06/28/2019 05:03:37 AM (4 years ago)
Author:
coffee2code
Message:

Developer: Output meta tag to prevent indexing of search results pages.

Props jonoaldersonwp, coffee2code.
Fixes #4540.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php

    r7827 r9000  
    2525        add_filter( 'posts_orderby', array( __CLASS__, 'search_posts_orderby' ), 10, 2 );
    2626        add_filter( 'the_posts',     array( __CLASS__, 'rerun_empty_search' ), 10, 2 );
     27        add_action( 'wp_head',       array( __CLASS__, 'noindex_for_search' ) );
     28    }
     29
     30    /**
     31     * Outputs `noindex,follow` robots tag for search results.
     32     */
     33    public static function noindex_for_search() {
     34        if ( is_search() ) {
     35            wp_no_robots();
     36        }
    2737    }
    2838
Note: See TracChangeset for help on using the changeset viewer.