yit_get_excluded_categories

Retrieve the escluded categories, set on Theme Options.

Description

(string) yit_get_excluded_categories( (int) $k = 1 ); 

Returns (string)

String with all id categories excluded, separated by a comma

Parameters (1)

0. $k — Optional. (int) => 1
The k.

Usage

  1. if ( !function_exists( 'yit_get_excluded_categories' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-compare/plugin-fw/yit-functions.php'; 
  3.  
  4. // The k. 
  5. $k = 1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = yit_get_excluded_categories($k); 
  9.  

Defined (1)

The function is defined in the following location(s).

/plugin-fw/yit-functions.php  
  1. function yit_get_excluded_categories ( $k = 1 ) { 
  2.  
  3. global $post; 
  4.  
  5. if ( ! isset( $post->ID ) ) { 
  6. return; 
  7.  
  8. $cf_cats = get_post_meta ( $post->ID, 'blog-cats', true ); 
  9.  
  10. if ( ! empty( $cf_cats ) ) { 
  11. return $cf_cats; 
  12.  
  13. $cats = function_exists ( 'yit_get_option' ) ? yit_get_option ( 'blog-excluded-cats' ) : ''; 
  14.  
  15.  
  16. if ( ! is_array ( $cats ) || empty( $cats ) || ! isset( $cats[ $k ] ) ) { 
  17. return; 
  18.  
  19. $cats = array_map ( 'trim', $cats[ $k ] ); 
  20.  
  21. $i = 0; 
  22. $query = ''; 
  23. foreach ( $cats as $cat ) { 
  24. $query .= ", -$cat"; 
  25.  
  26. $i ++; 
  27.  
  28. ltrim ( ', ', $query ); 
  29.  
  30. return $query;