How do I display the meta box information on Custom Post Type
-
I have read the documentation in detail, repeatedly, but I can’t get the custom meta info to display on my custom post types on the front end.
I have had no problem creating the metaboxes in the admin area for the custom post types, but how do we display it?
I see this bit of information:
rwmb_meta( $key, $args = array(), $post_id = null );
Where does this go? Does it go in functions.php or meta-box.php, or in the custom files I created for the meta boxes?
This is the code in my functions.php:
// CUSTOM METABOXES
// Re-define meta box path and URL define( 'RWMB_URL', trailingslashit( get_stylesheet_directory_uri() . '/includes/meta-box' ) ); define( 'RWMB_DIR', trailingslashit( STYLESHEETPATH . '/includes/meta-box' ) ); // Include the meta box script require_once RWMB_DIR . 'meta-box.php'; // Include the meta box script (THIS IS WHERE THE CUSTOM TYPES META BOXES ARE DEFINED) require_once RWMB_DIR . 'custom-meta-rugs.php'; require_once RWMB_DIR . 'custom-meta-carpets.php'; require_once RWMB_DIR . 'custom-meta-design.php'; require_once RWMB_DIR . 'custom-meta-wooden.php';
and an example of one the custom meta box files:
<?php /** * Registering meta boxes * * All the definitions of meta boxes are listed below with comments. * Please read them CAREFULLY. * * You also should read the changelog to know what has been changed before updating. * * For more information, please visit: * @link https://www.deluxeblogtips.com/meta-box/ */ /********************* META BOX DEFINITIONS ***********************/ /** * Prefix of meta keys (optional) * Use underscore (_) at the beginning to make keys hidden * Alt.: You also can make prefix empty to disable it */ add_action( 'admin_init', 'carpet_register_meta_boxes' ); function carpet_register_meta_boxes() { if ( ! class_exists( 'RW_Meta_Box' ) ) return; $prefix = 'carpet_'; $meta_boxes = array(); // Here is the code to define a meta box $meta_boxes[] = array( 'title' => 'Carpet Details', 'pages' => array( 'residential-carpets', 'commercial-carpets' ), 'fields' => array( array( 'name' => 'Product description', 'id' => $prefix . 'details', 'type' => 'wysiwyg', 'class' => 'custom-admin-boxes' ), array( 'name' => 'Real Name', 'id' => $prefix . 'realname', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Construction', 'id' => $prefix . 'constr', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Pile Fibre', 'id' => $prefix . 'pile', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Width', 'id' => $prefix . 'width', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Pile Weight', 'id' => $prefix . 'weight', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Colour Ways', 'id' => $prefix . 'colour', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Minimum Quants', 'id' => $prefix . 'quants', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Area Suitability', 'id' => $prefix . 'area', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Top Rating', 'id' => $prefix . 'rating', 'type' => 'text', 'size' => '90' ), array( 'name' => 'Total Height', 'id' => $prefix . 'height', 'type' => 'text', 'size' => '90' ), ) ); foreach ( $meta_boxes as $meta_box ) { new RW_Meta_Box( $meta_box ); } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How do I display the meta box information on Custom Post Type’ is closed to new replies.