Forum Replies Created
-
AuthorPosts
-
July 5, 2016 at 8:24 AM in reply to: Using custom function to include a metabox not working at all #3602
Anh Tran
KeymasterI tested with the same code for
pageand the meta box is not shown in the edit page. Do you use any other condition elsewhere? Or is the meta box hid by the Screen Options?Anh Tran
KeymasterHmm, Yoast is always a trouble :(. We had a problem with their JS once when they updated the free plugin to 3.0 version. And now the premium version :(.
Can you send me the premium version to email [email protected] to check? I donβt have it.
Anh Tran
KeymasterAh, yes, youβre right. The code I posted above is for the dev version on Github π
Anh Tran
KeymasterWhat are the role of the users? Do they have permission to upload images to the Media Library?
Anh Tran
KeymasterOh, I didn't notice that. Thanks a lot for reporting. I've just updated the extension with the fix.
June 28, 2016 at 3:05 PM in reply to: Is it possible to use the same metabox with default values in all post? #3562Anh Tran
KeymasterWhy don't use use
stdfor fields? So when creating a new post, all fields have default values. If an user wants another value, he can change it manually.Anh Tran
KeymasterYou can use filters to move the add more button to the top of the group:
add_filter( 'rwmb_FIELD_ID_begin_html', function( $output, $field ) { $output .= RWMB_Clone::add_clone_button( $field ); return $output; }, 10, 2 ); add_filter( 'rwmb_FIELD_ID_end_html', function( $output, $field ) { return RWMB_Field::call( 'element_description', $field ) . '</div>'; } );Note that this doesn't change the behaviour of the button, e.g. when clicking on it, the new clone will be added to the bottom of the group.
Anh Tran
KeymasterHey Ben,
This sample code registers a group of fields: contact name, contact email, contact phone number:
add_filter( 'rwmb_meta_boxes', 'prefix_register_contacts' ); function prefix_register_contacts( $meta_boxes ) { $meta_boxes[] = array( 'title' => __( 'Contacts', 'textdomain' ), 'post_types' => 'post', 'fields' => array( array( 'id' => 'contacts', 'type' => 'group', 'clone' => true, 'fields' => array( array( 'id' => 'name', 'type' => 'text', 'name' => __( 'Name', 'textdomain' ), ), array( 'id' => 'email', 'type' => 'text', 'name' => __( 'Email', 'textdomain' ), ), array( 'id' => 'phone', 'type' => 'text', 'name' => __( 'Phone', 'textdomain' ), ), ), ), ), ); return $meta_boxes; }In the
single.php, you can add the following code to display contacts:$contacts = rwmb_meta( 'contacts' ); if ( ! empty( $contacts ) ) { foreach ( $contacts as $contact ) { echo '<div class="contact">'; echo '<h4>', __( 'Contact info', 'textdomain' ), '</h4>'; echo '<p><label>', __( 'Name:', 'textdomain' ), '<label> ', $contact['name'], '</p>'; echo '<p><label>', __( 'Email:', 'textdomain' ), '<label> ', $contact['email'], '</p>'; echo '<p><label>', __( 'Phone number:', 'textdomain' ), '<label> ', $contact['phone'], '</p>'; echo '</div>'; } }Anh Tran
KeymasterHi,
The contact field is a cloned field, so it has values as an array. To output its values, you need to use a
foreachloop, as this:$settings = get_option( 'ims_settings' ); $field_id = 'ims_settings_default_mf_company_contact'; if ( !empty( $settings[$field_id] ) && is_array( $settings[$field_id] ) ) { foreach ( $settings[$field_id] as $field_value ) { echo $field_value, '<br>'; } }Anh Tran
KeymasterHi Flikweert, thanks for reporting it. I will check it soon later today.
Anh Tran
KeymasterI'm sorry but the price for the Group can't be changed.
Your code doesn't work because you don't have the Group extension. Please consider buying it.
Anh Tran
KeymasterSorry, the validation hasn't worked for media fields for now :(. We use complicated JS to handle upload/insert files and generate the HTML dynamically. That makes the validation JS not work π
Anh Tran
KeymasterCan you give me more info about your system?
1) Do you install the Meta Box as a standalone plugin? I see you included in a plugin, but is it also installed as a standalone plugin?
2) Which PHP version are you using?Anh Tran
KeymasterI think I answered this question in this topic. Please try.
Anh Tran
KeymasterThanks for your idea. We're planing to do this π
-
AuthorPosts