Advertisement
teastudio

wpc_item_categories

Feb 18th, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. function custom_wpc_item_categories( $category, $params ) {
  2.     if ( $params['params']['show_category'] === 'true' ) {
  3.         $categories_list = get_the_terms($params['post']->ID, $params['post_type_category']);
  4.         $count_$categories_list = count($categories_list);
  5.  
  6.         if ( $categories_list ) {
  7.             $category = '<p class="wp-posts-carousel-categories">';
  8.             foreach ( $categories_list as $cat ) {
  9.  
  10.                 /*
  11.                 * your condition to display only selected categories
  12.                  */
  13.                 if ( $categories_list > 1 && $cat->term_id != 8) {
  14.  
  15.                     $category .= '<a href="' . get_category_link($cat->term_id) . '" title="' . esc_attr(sprintf(__("View all items in %s") , $cat->name)) . '">' . $cat->name . '</a> ';
  16.                 }
  17.             }
  18.             $category .= '</p>';
  19.         }
  20.     }    
  21.     return $category;
  22. }
  23.  
  24. add_filter('wpc_item_categories', 'custom_wpc_item_categories', 1, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement