dragunoff

wpquestions.com, ID = 3611(3)

Dec 27th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. add_filter( 'post_class', 'wpq_filter_post_class' );
  3.  
  4. function wpq_filter_post_class( $classes ) {
  5.    
  6.     if( is_singular() ) {
  7.        
  8.         global $post;
  9.        
  10.         $taxonomies = get_taxonomies( array( 'public' => true ) , 'names', 'and' );
  11.  
  12.         if ( is_array($taxonomies) ) {
  13.             foreach ( $taxonomies as $taxonomy ) {
  14.                 if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
  15.                     foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
  16.                         if ( empty($term->slug ) || 'post_tag' == $taxonomy || 'category' == $taxonomy ) {
  17.                             continue;
  18.                         } else {
  19.                             $classes[] = sanitize_html_class( $term->slug, $term->term_id );
  20.                         }
  21.                     }
  22.                 }
  23.             }
  24.         }
  25.     }
  26.    
  27.     return $classes;
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment