From 79c38419bfdcb76bc68c41c653267e44e51d7ba1 Mon Sep 17 00:00:00 2001 From: scribu Date: Fri, 5 Nov 2010 12:47:19 +0000 Subject: [PATCH] Skip category/tag queries if post type doesn't support them. Props mfields. Fixes #15322 git-svn-id: https://develop.svn.wordpress.org/trunk@16204 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post-template.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 1acd9f8a0e..2dd4a94dd8 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -344,17 +344,21 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = 'hentry'; // Categories - foreach ( (array) get_the_category($post->ID) as $cat ) { - if ( empty($cat->slug ) ) - continue; - $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID); + if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) { + foreach ( (array) get_the_category($post->ID) as $cat ) { + if ( empty($cat->slug ) ) + continue; + $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID); + } } // Tags - foreach ( (array) get_the_tags($post->ID) as $tag ) { - if ( empty($tag->slug ) ) - continue; - $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); + if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) { + foreach ( (array) get_the_tags($post->ID) as $tag ) { + if ( empty($tag->slug ) ) + continue; + $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); + } } if ( !empty($class) ) {