Advertisement
fauzanjeg

Remove Featured Image in Post by Specific Category

Jul 28th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. /* Remove Featured Image in Post by Specific Category */
  2. function remove_featured_image_post_by_category( $output, $post_id ) {
  3.     $list_category_by_slug = array( 'uncategorized', 'video' );
  4.     $category_post_have = get_the_category( $post_id );
  5.     foreach ( $category_post_have as $post_category ) {
  6.         if ( in_array( $post_category->slug, $list_category_by_slug ) ) {
  7.             return '';
  8.         }
  9.     }
  10.  
  11.     return $output;
  12. }
  13.  
  14. add_filter( 'jnews_featured_image', 'remove_featured_image_post_by_category', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement