Make WordPress Core

Ticket #15407: 15407.diff

File 15407.diff, 787 bytes (added by nacin, 11 years ago)
  • wp-includes/category-template.php

     
    6464 * @return array
    6565 */
    6666function get_the_category( $id = false ) {
    67         $categories = get_the_terms( $id, 'category' );
     67        $categories = (array) get_the_terms( $id, 'category' );
    6868
    69         foreach ( array_keys( (array) $categories ) as $key ) {
    70                 _make_cat_compat( $categories[$key] );
     69        if ( $categories ) {
     70                foreach ( array_keys( $categories ) as $key ) {
     71                        _make_cat_compat( $categories[$key] );
     72                }
    7173        }
     74
    7275        // Filter name is plural because we are return alot of categories not just one
    7376        return apply_filters( 'get_the_categories', $categories );
    7477}