Skip category/tag queries if post type doesn't support them. Props mfields. Fixes #15322
git-svn-id: http://svn.automattic.com/wordpress/trunk@16204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
93bb73ea88
commit
e7318d2068
|
@ -344,18 +344,22 @@ function get_post_class( $class = '', $post_id = null ) {
|
||||||
$classes[] = 'hentry';
|
$classes[] = 'hentry';
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
|
if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) {
|
||||||
foreach ( (array) get_the_category($post->ID) as $cat ) {
|
foreach ( (array) get_the_category($post->ID) as $cat ) {
|
||||||
if ( empty($cat->slug ) )
|
if ( empty($cat->slug ) )
|
||||||
continue;
|
continue;
|
||||||
$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
|
$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
|
if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) {
|
||||||
foreach ( (array) get_the_tags($post->ID) as $tag ) {
|
foreach ( (array) get_the_tags($post->ID) as $tag ) {
|
||||||
if ( empty($tag->slug ) )
|
if ( empty($tag->slug ) )
|
||||||
continue;
|
continue;
|
||||||
$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
|
$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !empty($class) ) {
|
if ( !empty($class) ) {
|
||||||
if ( !is_array( $class ) )
|
if ( !is_array( $class ) )
|
||||||
|
|
Loading…
Reference in New Issue