- This topic has 3 replies, 2 voices, and was last updated 9 months, 1 week ago by .
-
Topic
-
Hi,
I have a strange issue that has been driving me crazy. I have a published field group that will not display on the front end via shortcode.
I have several other shortcodes that are almost identical (different custom field groups) and displaying content on the front end in Beaver Themer, but no matter what I do this one only ever returns an empty() result for the custom fields.
Can anyone give me any suggestions as to why I can retrieve and display these custom fields on the front end?
Here’s the code from the custom fields settings:
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = array ( 'title' => esc_html__( 'Composition', 'text-domain' ), 'id' => 'composition', 'post_types' => array( 0 => 'sock', ), 'context' => 'normal', 'priority' => 'low', 'fields' => array( array ( 'id' => $prefix . 'percent_combed_cotton', 'type' => 'number', 'name' => esc_html__( 'Combed Cotton', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_cotton', 'type' => 'number', 'name' => esc_html__( 'Cotton', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_nylon', 'type' => 'number', 'name' => esc_html__( 'Nylon', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_elastane', 'type' => 'number', 'name' => esc_html__( 'Elastane', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_spandex', 'type' => 'number', 'name' => esc_html__( 'Spandex', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_wool', 'type' => 'number', 'name' => esc_html__( 'Wool', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_merino', 'type' => 'number', 'name' => esc_html__( 'Merino Wool', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_acrylic', 'type' => 'number', 'name' => esc_html__( 'Acrylic', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'percent_elastic', 'type' => 'number', 'name' => esc_html__( 'Elastic', 'text-domain' ), 'max' => 100, 'step' => 1, 'columns' => 3, ), ), ); return $meta_boxes; }
Here is the shortcode:
/** * @return false|string * * Shortcode to display compositon */ function sock_composition_func() { $sockcomp = rwmb_meta('composition'); ob_start(); if ( empty( $sockcomp ) ) { return 'no sock composition found'; } print_r($sockcomp); // my output code will go here but it never displays because $sockcomp always returns empty() return ob_get_clean(); } add_shortcode('sock_composition', 'sock_composition_func');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.