Advertisement
Guest User

Untitled

a guest
Feb 18th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. add_filter('nectar_post_grid_excerpt','salient_child_cpt_cat_output');
  2.  
  3. function salient_child_cpt_cat_output($output) {
  4. global $post;
  5.  
  6. $category_markup = '<span class="meta-category">';
  7.  
  8. $cpt_categories = get_the_terms($post->id,"YOUR_TAXONOMY_SLUG");
  9.  
  10. if ( !empty($cpt_categories) ){
  11.  
  12. foreach ( $cpt_categories as $term ) {
  13.  
  14. if( isset($term->slug) ) {
  15. $category_markup .= '<a class="' . esc_attr( $term->slug ) . '" href="' . esc_url( get_category_link( $term->term_id ) ) . '">' . esc_html( $term->name ) . '</a>';
  16. }
  17. }
  18.  
  19. }
  20.  
  21. $category_markup .= '</span>';
  22.  
  23. return $category_markup . $output;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement