Skip to content

Instantly share code, notes, and snippets.

@JayWood
Created October 7, 2014 15:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayWood/d6f8a0cfe1f845788106 to your computer and use it in GitHub Desktop.
Save JayWood/d6f8a0cfe1f845788106 to your computer and use it in GitHub Desktop.
tech-tax.php
<?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