yourprefix_hide_if_no_cats

Conditionally displays a field when used as a callback in the 'show_on_cb' field parameter.

Description

yourprefix_hide_if_no_cats( (CMB2_Field) $field ); 

Parameters (1)

0. $field (CMB2_Field)
Object $field Field object

Usage

  1. if ( !function_exists( 'yourprefix_hide_if_no_cats' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'cmb2/example-functions.php'; 
  3.  
  4. // object $field Field object 
  5. $field = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = yourprefix_hide_if_no_cats($field); 
  9.  

Defined (1)

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

/example-functions.php  
  1. function yourprefix_hide_if_no_cats( $field ) { 
  2. // Don't show this field if not in the cats category 
  3. if ( ! has_tag( 'cats', $field->object_id ) ) { 
  4. return false; 
  5. return true;