WordPress.org

Make WordPress Core

Changeset 16204


Ignore:
Timestamp:
11/05/10 12:47:19 (3 years ago)
Author:
scribu
Message:

Skip category/tag queries if post type doesn't support them. Props mfields. Fixes #15322

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r16200 r16204  
    345345 
    346346    // Categories 
    347     foreach ( (array) get_the_category($post->ID) as $cat ) { 
    348         if ( empty($cat->slug ) ) 
    349             continue; 
    350         $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID); 
     347    if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) { 
     348        foreach ( (array) get_the_category($post->ID) as $cat ) { 
     349            if ( empty($cat->slug ) ) 
     350                continue; 
     351            $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID); 
     352        } 
    351353    } 
    352354 
    353355    // Tags 
    354     foreach ( (array) get_the_tags($post->ID) as $tag ) { 
    355         if ( empty($tag->slug ) ) 
    356             continue; 
    357         $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); 
     356    if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) { 
     357        foreach ( (array) get_the_tags($post->ID) as $tag ) { 
     358            if ( empty($tag->slug ) ) 
     359                continue; 
     360            $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); 
     361        } 
    358362    } 
    359363 
Note: See TracChangeset for help on using the changeset viewer.