Advertisement
vapvarun

Add post categories in class

Feb 8th, 2022
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /**
  2.  * Add post categories in class
  3.  *
  4.  * @param  mixed $output return html.
  5.  * @return $output
  6.  */
  7. function reign_post_categories_callback( $output ) {
  8.     global $post;
  9.     $post_id       = $post->ID;
  10.     $post_category = get_the_category( $post->ID );
  11.     $cat_name      = '';
  12.     foreach ( $post_category as $post_key => $post_val ) {
  13.             $cat_name .= $post_val->slug . ' ';
  14.     }
  15.     $output = str_replace( 'cat-links', 'cat-links ' . $cat_name, $output );
  16.     return $output;
  17. }
  18. add_filter( 'reign_post_categories', 'reign_post_categories_callback' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement