Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'post_class', 'wpq_filter_post_class' );
- function wpq_filter_post_class( $classes ) {
- if( is_singular() ) {
- global $post;
- $taxonomies = get_taxonomies( array( 'public' => true ) , 'names', 'and' );
- if ( is_array($taxonomies) ) {
- foreach ( $taxonomies as $taxonomy ) {
- if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
- foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
- if ( empty($term->slug ) || 'post_tag' == $taxonomy || 'category' == $taxonomy ) {
- continue;
- } else {
- $classes[] = sanitize_html_class( $term->slug, $term->term_id );
- }
- }
- }
- }
- }
- }
- return $classes;
- }
Advertisement
Add Comment
Please, Sign In to add comment