Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active October 10, 2015 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/3764446 to your computer and use it in GitHub Desktop.
Save jaredatch/3764446 to your computer and use it in GitHub Desktop.
Add taxonomy slugs to post class
<?php
/**
* Add taxonomy slugs to post class
*
* @author Jared Atchison
* @link http://jaredatchison.com/code/
* @param array $classes
* @global array $post
* @return array
*/
function ja_portfolio_post_class( $classes ){
global $post;
$custom_terms = get_the_terms( $post->ID, 'portfolio-features') ;
if ( $custom_terms ) {
foreach ( $custom_terms as $custom_term ) {
$classes[] = 'tax-' . $custom_term->slug;
}
}
return $classes;
}
add_filter( 'post_class', 'ja_portfolio_post_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment