Created
October 7, 2014 15:54
-
-
Save JayWood/d6f8a0cfe1f845788106 to your computer and use it in GitHub Desktop.
tech-tax.php
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 | |
/** | |
* Tax Filter | |
* Can be used as a filter, or standalone method. | |
*/ | |
function msft_openness_home_grid_post_tax_filter( $techclasses = array() ) { | |
$post = get_post(); | |
$terms = wp_get_post_terms( $post->ID, 'technology', array( 'fields' => 'slug' ) ); | |
if( empty( $terms ) || is_wp_error( $terms ) ) return $techclasses; | |
foreach ( $terms as $term ) { | |
$techclasses[] = 'technology-' . $term->slug; | |
} | |
return $techclasses; | |
} | |
/** | |
* Example: | |
* In a loop | |
*/ | |
$classes = msft_openness_home_grid_post_tax_filter(); | |
$post_class = get_post_class( $classes ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment