yourprefix_show_if_front_page

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

Description

yourprefix_show_if_front_page( (CMB2) $cmb ); 

Parameters (1)

0. $cmb (CMB2)
Object $cmb CMB2 object

Usage

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

Defined (1)

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

/example-functions.php  
  1. function yourprefix_show_if_front_page( $cmb ) { 
  2. // Don't show this metabox if it's not the front page template 
  3. if ( $cmb->object_id !== get_option( 'page_on_front' ) ) { 
  4. return false; 
  5. return true;