Making WordPress.org

Changeset 9460


Ignore:
Timestamp:
02/04/2020 12:14:58 AM (5 years ago)
Author:
coffee2code
Message:

Jobs theme: Noindex empty job category archives.

Props jonoaldersonwp, coffee2code.
Fixes #5001.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/jobs.wordpress.net/public_html/wp-content/themes/jobswp/functions.php

    r9454 r9460  
    130130
    131131/**
    132  * Outputs `noindex,follow` robots tag for search results.
     132 * Outputs `noindex,follow` robots tag for appropriate pages.
     133 *
     134 * Currently output for:
     135 * - empty job category archives
     136 * - search results
    133137 */
    134 function jobswp_noindex_for_search() {
    135     if ( is_search() ) {
     138function jobswp_noindex() {
     139    global $wp_query;
     140
     141    if (
     142        is_search()
     143    ||
     144        ( is_tax( 'job_category' ) && 0 === $wp_query->found_posts )
     145    ) {
    136146        wp_no_robots();
    137147    }
    138148}
    139 add_action( 'wp_head', 'jobswp_noindex_for_search', 9 );
     149add_action( 'wp_head', 'jobswp_noindex', 9 );
    140150
    141151/**
Note: See TracChangeset for help on using the changeset viewer.