EliWbbr
Forum Replies Created
-
Forum: Plugins
In reply to: [CMB2] admin array and header errorThis worked!! Oh my gosh thank you so so much for your time and patience ??
If I could I’d buy you a coffee (or a pint)
Thanks again Mr. Beckwith!
Forum: Plugins
In reply to: [CMB2] admin array and header errorAnd here is the Product custom post type:
`
<?php
function codex_cpt_init() {
// PRODUCTS
$labels_product = array(
‘name’ => _x(‘Products’, ‘post type general name’),
‘singular_name’ => _x(‘Product’, ‘post type singular name’),
‘add_new’ => _x(‘Add New’, ‘product’),
‘add_new_item’ => __(‘Add New Product’),
‘edit_item’ => __(‘Edit Product’),
‘new_item’ => __(‘New Product’),
‘view_item’ => __(‘View Product’),
‘search_items’ => __(‘Search Products’),
‘not_found’ => __(‘No products found’),
‘not_found_in_trash’ => __(‘No products found in Trash’),
‘parent_item_colon’ => ”,
‘menu_name’ => ‘Products’
);
$args_product = array(
‘labels’ => $labels_product,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘query_var’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘has_archive’ => true,
‘hierarchical’ => false,
//’menu_position’ => 25,
‘menu_icon’ => get_bloginfo(‘template_url’) . ‘/img/icon-products.png’,
‘supports’ => array(‘title’,’editor’,’thumbnail’) //,’excerpt’
);
register_post_type( ‘product’, $args_product );
}
add_action( ‘init’, ‘codex_cpt_init’ );
?>Forum: Plugins
In reply to: [CMB2] admin array and header errorShould it help, here is the code for the front end:
$boxcosts = get_post_meta( get_the_ID(), '_cmb2_box_cost_repeat_group', true ); echo '<tr>'; foreach ( (array) $boxcosts as $key => $boxcost ) { echo '<td>'; echo $boxcost['_cmb2_box_cost']; echo '</td>'; }; echo '</tr>';
Forum: Plugins
In reply to: [CMB2] admin array and header error“Specifically because you’re providing an object_types parameter for a field that doesn’t take them.”
I’m not entirely sure I understand you here. Can you explain that to me like I’m a 5 year old? I won’t be offended!!
Thank you again!
Forum: Plugins
In reply to: [CMB2] admin array and header error<?php /** * Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory) * * Be sure to replace all instances of 'products_' with your project's prefix. * https://nacin.com/2010/05/11/in-wordpress-prefix-everything/ * * @category YourThemeOrPlugin * @package Demo_CMB2 * @license https://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) * @link https://github.com/WebDevStudios/CMB2 */ /** * Get the bootstrap! If using the plugin from www.remarpro.com, REMOVE THIS! */ if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) { require_once dirname( __FILE__ ) . '/cmb2/init.php'; } elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) { require_once dirname( __FILE__ ) . '/CMB2/init.php'; } add_action( 'cmb2_init', 'cmb2_metaboxes' ); /*** Define the metabox and field configurations. */ function cmb2_metaboxes() { // Start with an underscore to hide fields from custom fields list $prefix = '_cmb2_'; /* -----------------------------------------------------------------------------*/ /* */ /* Initiate NEW! POPUP the metabox */ /* */ /* -----------------------------------------------------------------------------*/ //$cmb = new_cmb2_box( array( // 'id' => 'homepage_popup', // 'title' => __( 'Home page Pop-up', 'cmb2' ), // 'object_types' => array( 'post', 'product' ), // Post type // 'context' => 'side', // 'priority' => 'high', // 'show_names' => true, // Show field names on the left // 'cmb_styles' => true, // false to disable the CMB stylesheet // // 'closed' => true, // Keep the metabox closed by default //) ); // $cmb->add_field( array( // 'name' => 'Is this a Pop-up item?', // 'desc' => 'Ceck this box if you want a pop-up on the homepage', // 'id' => $prefix . 'popup_checkbox', // 'type' => 'checkbox', // ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate MASTHEAD SUBHEADING the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'masthead_subhead_metabox', 'title' => __( 'Masthead Subheading', 'cmb2' ), 'object_types' => array( 'page' ), // Post type (array ('post', 'product')) 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); $cmb->add_field( array( 'name' => __( 'Sub-heading', 'cmb2' ), 'desc' => __( 'Enter a sub-heading for this page (optional)', 'cmb2' ), 'id' => $prefix . 'masthead_subhead', 'type' => 'text', 'column' => array( 'position' => 5 ), ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate MASTHEAD IMAGE the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'masthead_fileupload', 'title' => __( 'Masthead', 'cmb2' ), 'object_types' => array( 'page' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); $cmb->add_field( array( 'name' => __( 'Masthead Image', 'cmb2' ), 'desc' => __( 'Upload a masthead image this page. If nothing is selected, a default image will be used.', 'cmb2' ), 'id' => $prefix . 'masthead_image', 'type' => 'file', 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 ) ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate PRODUCTS the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'products_metabox', 'title' => __( '<h1 class="patk_cmb2_h1">Products</h1>', 'cmb2' ), 'object_types' => array( 'post', 'product' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); $cmb->add_field( array( 'name' => __( 'Finish', 'cmb2' ), 'desc' => __( 'Enter a finish for this product', 'cmb2' ), 'id' => $prefix . 'finish', 'type' => 'text', //'column' => array( 'position' => 5 ), ) ); $cmb->add_field( array( 'name' => 'Species', 'desc' => __('Enter the species of wood for this product', 'cmb2'), 'id' => $prefix . 'species', 'type' => 'text', //'column' => array( 'position' => 7 ), ) ); $cmb->add_field( array( 'name' => 'Grade', 'desc' => 'Enter the grade of this product', 'id' => $prefix . 'grade', 'type' => 'text' ) ); $cmb->add_field( array( 'name' => 'Average Box Qty', 'desc' => 'Enter the average box quantity of this product', 'id' => $prefix . 'avg_box_qty', 'type' => 'text' ) ); $cmb->add_field( array( 'name' => 'Length', 'desc' => 'Enter the length of this product', 'id' => $prefix . 'length', 'type' => 'text', 'column' => array( 'position' => 5 ), ) ); $cmb->add_field( array( 'name' => 'Rabbet', 'desc' => 'Enter the rabbet depth for this product', 'id' => $prefix . 'rabbet', 'type' => 'text', 'column' => array( 'position' => 6 ), ) ); $cmb->add_field( array( 'name' => __( 'Large Image', 'cmb2' ), 'desc' => __( 'Upload a large image this product for customers to see detail.', 'cmb2' ), 'id' => $prefix . 'large_image', 'type' => 'file', 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 ) 'column' => array('position' => 10) ) ); $cmb->add_field( array( 'name' => __( '<h1>Enter the profile info fields below</h1>', 'cmb2' ), 'description' => __( '', 'cmb2' ), 'id' => $prefix . 'cost_title', 'type' => 'title', ) ); $cmb->add_field( array( 'name' => __( 'Profile Image', 'cmb2' ), 'desc' => __( 'Upload a profile image this product.', 'cmb2' ), 'id' => $prefix . 'profile_image', 'type' => 'file', 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 ) 'column' => array('position' => 7) ) ); $cmb->add_field( array( 'name' => __( 'Profile Width', 'cmb2' ), 'desc' => __( 'Enter the width of this profile.', 'cmb2' ), 'id' => $prefix . 'profile_width', 'type' => 'text', 'column' => array('position' => 8) ) ); $cmb->add_field( array( 'name' => __( 'Profile Thickness', 'cmb2' ), 'desc' => __( 'Enter the thickness of this profile.', 'cmb2' ), 'id' => $prefix . 'profile_thick', 'type' => 'text', 'column' => array('position' => 9) ) ); // REPEATABLE FIELDS FOR COST PER BOX SECTION $group_field_id = $cmb->add_field( array( 'id' => $prefix . 'box_cost_repeat_group', 'type' => 'group', 'object_types' => array( 'post', 'product' ), // Post type 'description' => __( '<h1>Enter the cost per box breakdowns in the fields below</h1>', 'cmb2' ), 'repeatable' => true, // use false if you want non-repeatable group 'options' => array( 'group_title' => __( 'Cost Per Box Breakdown {#}', 'cmb2' ), // {#} gets replaced by row number 'add_button' => __( 'Add Another Breakdown Option', 'cmb2' ), 'remove_button' => __( 'Remove Breakown', 'cmb2' ), //'sortable' => true, // beta ), ) ); // Id's for group's fields only need to be unique for the group. Prefix is not needed. $cmb->add_group_field( $group_field_id, array( 'name' => __( '# of Boxes', 'cmb2' ), 'id' => $prefix . 'box_count', 'type' => 'text_small', ) ); $cmb->add_group_field( $group_field_id, array( 'name' => __( '$ per Box', 'cmb2' ), 'description' => '', 'id' => $prefix . 'box_cost', 'type' => 'text', ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate DISTRIBUTORS the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'distributors_metabox', 'title' => __( 'Distributors', 'cmb2' ), 'object_types' => array( 'post', 'distributors' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); // Distributors & Location(s) // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. $cmb->add_field ( array( 'name' => __( 'Address', 'cmb2' ), 'id' => $prefix . 'distributor_address', 'type' => 'text', 'column' => array( 'position' => 2, 'name' => 'Address' ), // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) ) ); $cmb->add_field ( array( 'name' => __( 'City', 'cmb2' ), 'description' => '', 'id' => $prefix . 'distributor_city', 'type' => 'text', 'column' => array( 'position' => 3 ), ) ); $cmb->add_field ( array( 'name' => 'State', 'desc' => 'Select a State', 'id' => $prefix . 'state_select', 'type' => 'select', 'column' => array( 'position' => 4 ), 'default' => 'custom', 'options' => array( 'AL' => __( 'Alabama', 'cmb2' ), 'AK' => __( 'Alaska', 'cmb2' ), 'AZ' => __( 'Arizona', 'cmb2' ), 'AR' => __( 'Arkansas', 'cmb2' ), 'CA' => __( 'California', 'cmb2' ), 'CO' => __( 'Colorado', 'cmb2' ), 'CT' => __( 'Connecticut', 'cmb2' ), 'DE' => __( 'Delaware', 'cmb2' ), 'DC' => __( 'District of Columbia', 'cmb2' ), 'FL' => __( 'Florida', 'cmb2' ), 'GA' => __( 'Georgia', 'cmb2' ), 'HI' => __( 'Hawaii', 'cmb2' ), 'ID' => __( 'Idaho', 'cmb2' ), 'IL' => __( 'Illinois', 'cmb2' ), 'IN' => __( 'Indiana', 'cmb2' ), 'IA' => __( 'Iowa', 'cmb2' ), 'KS' => __( 'Kansas', 'cmb2' ), 'KY' => __( 'Kentucky', 'cmb2' ), 'LA' => __( 'Louisiana', 'cmb2' ), 'ME' => __( 'Maine', 'cmb2' ), 'MD' => __( 'Maryland', 'cmb2' ), 'MA' => __( 'Massachusetts', 'cmb2' ), 'MI' => __( 'Michigan', 'cmb2' ), 'MN' => __( 'Minnesota', 'cmb2' ), 'MS' => __( 'Mississippi', 'cmb2' ), 'MO' => __( 'Missouri', 'cmb2' ), 'MT' => __( 'Montana', 'cmb2' ), 'NE' => __( 'Nebraska', 'cmb2' ), 'NV' => __( 'Nevada', 'cmb2' ), 'NH' => __( 'New Hampshire', 'cmb2' ), 'NJ' => __( 'New Jersey', 'cmb2' ), 'NM' => __( 'New Mexico', 'cmb2' ), 'NY' => __( 'New York', 'cmb2' ), 'NC' => __( 'North Carolina', 'cmb2' ), 'ND' => __( 'North Dakota', 'cmb2' ), 'OH' => __( 'Ohio', 'cmb2' ), 'OK' => __( 'Oklahoma', 'cmb2' ), 'OR' => __( 'Oregon', 'cmb2' ), 'PA' => __( 'Pennsylvania', 'cmb2' ), 'RI' => __( 'Rhode Island', 'cmb2' ), 'SC' => __( 'South Carolina', 'cmb2' ), 'SD' => __( 'South Dakota', 'cmb2' ), 'TN' => __( 'Tennessee', 'cmb2' ), 'TX' => __( 'Texas', 'cmb2' ), 'UT' => __( 'Utah', 'cmb2' ), 'VT' => __( 'Vermont', 'cmb2' ), 'VA' => __( 'Virginia', 'cmb2' ), 'WA' => __( 'Washington', 'cmb2' ), 'WV' => __( 'West Virginia', 'cmb2' ), 'WI' => __( 'Wisconsin', 'cmb2' ), 'WY' => __( 'Wyoming', 'cmb2' ), ), ) ); $cmb->add_field ( array( 'name' => __( 'Zip Code', 'cmb2' ), 'description' => '', 'id' => $prefix . 'distributor_zip', 'type' => 'text', 'column' => array( 'position' => 5 ), ) ); $cmb->add_field ( array( 'name' => __( 'Phone', 'cmb2' ), 'description' => '', 'id' => $prefix . 'distributor_phone', 'type' => 'text', 'column' => array( 'position' => 6 ), //'repeatable' => true, ) ); $cmb->add_field ( array( 'name' => __( 'Fax', 'cmb2' ), 'description' => '', 'id' => $prefix . 'distributor_fax', 'type' => 'text', ) ); $cmb->add_field( array( 'name' => __( 'Website', 'cmb2' ), 'id' => 'website', 'type' => 'text_url', // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols ) ); $cmb->add_field( array( 'name' => __( 'Email Address', 'cmb2' ), 'id' => 'dist_email', 'type' => 'text_email', // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate STAFF the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'staff_metabox', 'title' => __( 'Staff', 'cmb2' ), 'object_types' => array( 'post', 'staff' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. $cmb->add_field ( array( 'name' => __( 'Title', 'cmb2' ), 'id' => $prefix . 'staff_title', 'type' => 'text', 'column' => array( 'position' => 2, 'name' => 'Title' ), // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) ) ); $cmb->add_field ( array( 'name' => __( 'Office Phone', 'cmb2' ), 'description' => '', 'id' => $prefix . 'staff_phone', 'type' => 'text', 'column' => array( 'position' => 6 ), //'repeatable' => true, ) ); $cmb->add_field ( array( 'name' => __( 'Staff Cell', 'cmb2' ), 'description' => '', 'id' => $prefix . 'staff_cell', 'type' => 'text', ) ); $cmb->add_field( array( 'name' => __( 'Email Address', 'cmb2' ), 'id' => 'staff_email', 'type' => 'text_email', // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols ) ); $cmb->add_field( array( 'name' => __( 'Email Address', 'cmb2' ), 'id' => 'staff_email', 'type' => 'text_email', // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols ) ); $cmb->add_field( array( 'name' => __( 'Staff Pic', 'cmb2' ), 'desc' => __( 'Upload a pic of this staff member if available. If nothing is selected, the default image will be used.', 'cmb2' ), 'id' => $prefix . 'staff_image', 'type' => 'file', 'preview_size' => 'small', ) ); /* -----------------------------------------------------------------------------*/ /* */ /* Initiate SALES REPS the metabox */ /* */ /* -----------------------------------------------------------------------------*/ $cmb = new_cmb2_box( array( 'id' => 'reps_metabox', 'title' => __( 'Sales Reps', 'cmb2' ), 'object_types' => array( 'post', 'reps' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'cmb_styles' => true, // false to disable the CMB stylesheet // 'closed' => true, // Keep the metabox closed by default ) ); // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. $cmb->add_field ( array( 'name' => __( 'Phone', 'cmb2' ), 'description' => '', 'id' => $prefix . 'reps_phone', 'type' => 'text', 'column' => array( 'position' => 6 ), //'repeatable' => true, ) ); $cmb->add_field ( array( 'name' => __( 'Cell', 'cmb2' ), 'description' => '', 'id' => $prefix . 'reps_cell', 'type' => 'text', ) ); $cmb->add_field ( array( 'name' => __( 'Fax', 'cmb2' ), 'description' => '', 'id' => $prefix . 'reps_fax', 'type' => 'text', ) ); $cmb->add_field( array( 'name' => __( 'Email Address', 'cmb2' ), 'id' => 'reps_email', 'type' => 'text_email', // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols ) ); $cmb->add_field( array( 'name' => __( 'Reps Pic', 'cmb2' ), 'desc' => __( 'Upload a pic of this sales rep if available. If nothing is selected, the default image will be used.', 'cmb2' ), 'id' => $prefix . 'reps_image', 'type' => 'file', 'preview_size' => array( 80, 80 ), // Default: array( 50, 50 ) 'column' => array('position' => 9) ) ); // Add other metaboxes as needed } /* -----------------------------------------------------------------------------*/ /* */ /* Initiate TAXONOMY IMAGES the metabox */ /* */ /* -----------------------------------------------------------------------------*/ add_action( 'cmb2_init', 'cmb2_register_taxonomy_metabox' ); /* Hook in and add a metabox to add fields to taxonomy terms */ function cmb2_register_taxonomy_metabox() { $prefix = '_cmb2_term_'; /* Metabox to add fields to categories and tags */ $cmb_term = new_cmb2_box( array( 'id' => $prefix . 'edit', 'title' => esc_html__( 'Department Image', 'cmb2' ), // Doesn't output for term boxes 'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta 'taxonomies' => array( 'department', 'post_tag' ), // Tells CMB2 which taxonomies should have these fields 'new_term_section' => true, // Will display in the "Add New Category" section ) ); $cmb_term->add_field( array( 'name' => esc_html__( 'Department Image', 'cmb2' ), 'desc' => esc_html__( 'Add an image to represent this department', 'cmb2' ), 'id' => $prefix . 'dept_img', 'type' => 'file', 'column' => array( 'position' => 8 ), ) ); // Add other metaboxes as needed }
Forum: Plugins
In reply to: [CMB2] admin array and header errorSorry for the delay, i got pulled onto another project. Hopefully we can continue here. I still cannot log into wp-admin the error reads:
Notice: Array to string conversion in /../../../../../wp-content/themes/patk_nickell/cmb2/includes/CMB2_Hookup.php on line 141
<br />
Warning: Cannot modify header information – headers already sent by (output started at /../../../../../wp-content/themes/patk_nickell/cmb2/includes/CMB2_Hookup.php:141) in /../../../../../wp-includes/pluggable.php on line 1296I do not have any multiple object types; they are either for a specific page or a specific posttype. I can provide if you like.
Let me know what you think. And thanks so much for the continued help!
Forum: Plugins
In reply to: [CMB2] admin array and header errorUnfortunately it did not :/
Forum: Plugins
In reply to: [CMB2] admin array and header errorGood morning!
Thank you for your response. i do have another field i’m using multiple parameters for:/* —————————————————————————–*/
/* */
/* Initiate MASTHEAD SUBHEADING the metabox */
/* */
/* —————————————————————————–*/
$cmb = new_cmb2_box( array(
‘id’ => ‘masthead_subhead_metabox’,
‘title’ => __( ‘Masthead Subheading’, ‘cmb2’ ),
‘object_types’ => array( ‘page’, (array (‘post’, ‘product’)) ), // Post type
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘show_names’ => true, // Show field names on the left
‘cmb_styles’ => true, // false to disable the CMB stylesheet
// ‘closed’ => true, // Keep the metabox closed by default
) );
$cmb->add_field( array(
‘name’ => __( ‘Sub-heading’, ‘cmb2’ ),
‘desc’ => __( ‘Enter a sub-heading for this page (optional)’, ‘cmb2’ ),
‘id’ => $prefix . ‘masthead_subhead’,
‘type’ => ‘text’,
‘column’ => array( ‘position’ => 5 ),
) );Though i never noticed any issues with text field.
Per your suggestions above, i’ve limited the object_types to just pages:
/* —————————————————————————–*/
/* */
/* Initiate MASTHEAD IMAGE the metabox */
/* */
/* —————————————————————————–*/
$cmb = new_cmb2_box( array(
‘id’ => ‘masthead_fileupload’,
‘title’ => __( ‘Masthead’, ‘cmb2’ ),
‘object_types’ => array( ‘page’ ), // Post type
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘show_names’ => true, // Show field names on the left
‘cmb_styles’ => true, // false to disable the CMB stylesheet
// ‘closed’ => true, // Keep the metabox closed by default
) );$cmb->add_field( array(
‘name’ => __( ‘Masthead Image’, ‘cmb2’ ),
‘desc’ => __( ‘Upload a masthead image this page. If nothing is selected, a default image will be used.’, ‘cmb2’ ),
‘id’ => $prefix . ‘masthead_image’,
‘type’ => ‘file’,
‘preview_size’ => array( 100, 100 ), // Default: array( 50, 50 )
) );Hope this helps. Thanks so much for your continued help!! ??
Forum: Plugins
In reply to: [CMB2] admin array and header errorHello Mr Beckwith,
Thank you for your suggestions. I made them. And tested the front end. And it worked as it should, there is an image loaded into that page on the admin. Then I tried logging into the back end to see if removing the image form the metabox would prompt a predetermined image to appear. But i can’t seem to get into the wp admin at all now..? Here is a screen shot: https://staging21.thestudio-patrick.com/images/cannot-access-admin.jpgHope you can help again!
Thank you in advance!!
Forum: Plugins
In reply to: [CMB2] admin array and header errorYou bet, here you go:
/*** Define the metabox and field configurations. */
function cmb2_metaboxes() {// Start with an underscore to hide fields from custom fields list
$prefix = ‘_cmb2_’;
/* —————————————————————————–*/
/* */
/* Initiate MASTHEAD IMAGE the metabox */
/* */
/* —————————————————————————–*/
$cmb = new_cmb2_box( array(
‘id’ => ‘masthead_fileupload’,
‘title’ => __( ‘Masthead’, ‘cmb2’ ),
‘object_types’ => array( ‘page’, (array (‘post’, ‘product’)) ), // Post type
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘show_names’ => true, // Show field names on the left
‘cmb_styles’ => true, // false to disable the CMB stylesheet
// ‘closed’ => true, // Keep the metabox closed by default
) );$cmb->add_field( array(
‘name’ => __( ‘Masthead Image’, ‘cmb2’ ),
‘desc’ => __( ‘Upload a masthead image this page. If nothing is selected, a default image will be used.’, ‘cmb2’ ),
‘id’ => $prefix . ‘masthead_image’,
‘type’ => ‘file’,
‘preview_size’ => array( ‘100, 100’ ), // Default: array( 50, 50 )
) );}
And here is how i’m trying to pull it into the front end:
<!– Masthead Banner –>
<!– foreach ( (array) $locations as $key => $location ) –>
<?php
$masthead_imgs = get_post_meta(get_the_ID(), ‘_cmb2_masthead_image’, true);
//$masthead_imgs = wp_get_attachment_image( get_post_meta( get_the_ID(), ‘_cmb2_masthead_image’, 1 ), ‘medium’ );
if( !empty ($masthead_imgs)) { ?><section id=”<?php the_id(); ?>”
data-type=”background”
data-speed=”15″
style=”border:1px solid blue;background: url("<?php foreach( (array) $masthead_imgs as $masthead) { echo $masthead; } ?>") 50% 0 / cover repeat fixed; min-height: 320px; height: 100%; width: 100%; position: relative;”>
</section><?php } else { ?>
<section id=”<?php the_id(); ?>”
data-type=”background”
data-speed=”10″
style=”border:1px solid red; background: url(‘<?php bloginfo(‘template_directory’); ?>/img/masthead.jpg’) 50% 0 / cover repeat fixed; min-height: 320px; height: 100%; width: 100%; position: relative;”>
</section><?php } ?>
Hope that helps, please let me know if you would like anything else!
Thanks for the continued support! ??
Note: i am not using GravityView
Forum: Plugins
In reply to: [CMB2] Forms on the front endPlease pardon my ignorance here. Can you help me understand why i don’t have to use this technique to display the form fields on the page?
<?php $text = get_post_meta( $post->ID, '_cmb2_sample_address', true ); echo $text; echo '<br />'; $text = get_post_meta( $post->ID, '_cmb2_sample_city', true ); echo $text; echo ', '; $select = get_post_meta( $post->ID, '_cmb2_sample_state', true ); echo $select; echo ' '; $text = get_post_meta( $post->ID, '_cmb2_sample_zip', true ); echo $text; ?>
I followed the CMB2-Snippet-Library/front-end/ example, so everything exists on frontend-form.php; registered objects and fields. And then the shortcode was put on a page in the admin.
I know i’m working on the front-end, not the admin-side of things…but i can’t seem to find an answer to this and i feel like i’m missing a critical connection in my understanding of this.
You can pretend explaining it to a 5 year old…i won’t be offended ??
Forum: Plugins
In reply to: [CMB2] Forms on the front endOkay, I’ve had a chance to play with the cmb2-conditionals files. Do you have any links to reference those extra steps needed to make it work on the front end?
Thanks Michael!Forum: Plugins
In reply to: [CMB2] Forms on the front endHi Michael! I just gave this a quick look, but feel better about tackling this project now after peeking at the example functions file. I’ll be able to dig into it more tomorrow! Thanks so much
Forum: Plugins
In reply to: [CMB2] Custom Taxonomy Image on front-endHi Michael-
Here is it is in pastebin:
https://pastebin.com/vbyh3pyk(is this what you meant? its my first time using it)