Advertisement
arie_cristianD

disable inlinie ads in spesific category

Jun 23rd, 2024
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. add_filter( 'jnews_ads_global_enable', 'disable_ads_in_categories', 10, 3 );
  2.  
  3. function disable_ads_in_categories( $flag, $post_id, $location ) {
  4.  
  5.     if ( get_post_type() === 'post' && is_single() && $flag && 'content_inline' === $location ) {
  6.         $cat_id_list = array( 2, 4 ); /* cat id list that wont displayed the ads. */
  7.         $catgegories = jnews_get_primary_category( $post_id );
  8.         if ( in_array( $catgegories, $cat_id_list ) ) {
  9.             return false;
  10.         }
  11.     }
  12.     return $flag;
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement