Last active
October 10, 2015 22:58
-
-
Save jaredatch/3764446 to your computer and use it in GitHub Desktop.
Add taxonomy slugs to post class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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