yourprefix_register_about_page_metabox

Hook in and add a metabox that only appears on the 'About' page.

Description

yourprefix_register_about_page_metabox(); 

Usage

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

Defined (1)

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

/example-functions.php  
  1. function yourprefix_register_about_page_metabox() { 
  2. $prefix = 'yourprefix_about_'; 
  3.  
  4. /** 
  5. * Metabox to be displayed on a single page ID 
  6. */ 
  7. $cmb_about_page = new_cmb2_box( array( 
  8. 'id' => $prefix . 'metabox',  
  9. 'title' => esc_html__( 'About Page Metabox', cmb2 ),  
  10. 'object_types' => array( 'page', ), // Post type 
  11. 'context' => 'normal',  
  12. 'priority' => 'high',  
  13. 'show_names' => true, // Show field names on the left 
  14. 'show_on' => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox 
  15. ) ); 
  16.  
  17. $cmb_about_page->add_field( array( 
  18. 'name' => esc_html__( 'Test Text', cmb2 ),  
  19. 'desc' => esc_html__( 'field description (optional)', cmb2 ),  
  20. 'id' => $prefix . 'text',  
  21. 'type' => 'text',  
  22. ) ); 
  23.