Making WordPress.org

Changeset 10852


Ignore:
Timestamp:
03/26/2021 10:12:00 PM (5 years ago)
Author:
coffee2code
Message:

Jobs theme: Check return value of get_the_terms() before use to prevent warnings/errors.

File:
1 edited

Legend:

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

    r1604 r10852  
    1616            <span class="job-categories">
    1717                <?php echo get_the_category_list(); ?>
    18                 <?php foreach ( get_the_terms( get_the_ID(), 'job_category' ) as $job_cat ) : ?>
     18                <?php
     19                    $job_cats = get_the_terms( get_the_ID(), 'job_category' );
     20                    if ( $job_cats && ! is_wp_error( $job_cats ) ) :
     21                        foreach ( $job_cats as $job_cat ) :
     22                ?>
    1923                    <span class="job-cat-item job-cat-item-<?php echo esc_attr( $job_cat->slug ); ?>"><?php echo esc_html( $job_cat->name ); ?></span>
    20                 <?php endforeach; ?>
     24                <?php
     25                        endforeach;
     26                    endif;
     27                ?>
    2128            </span>
    2229        </div><!-- .entry-meta -->
Note: See TracChangeset for help on using the changeset viewer.