Advertisement
fauzanjeg

Only Show 2 Category in Single Post

Aug 8th, 2021
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. /* Only Show 2 Category in Single Post */
  2. function show_only_2_category( $thelist ) {
  3.     if ( is_single() && is_singular() ) {
  4.         $thelist = array( $thelist[0], $thelist[1] ); /* Set Only First 2 Category */
  5.         return $thelist;
  6.     }
  7.  
  8.     return $thelist;
  9. }
  10. add_filter( 'the_category_list', 'show_only_2_category', 999 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement