Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi lukeragno,
I've tested your code and couldn't detect the problem. It works fine to me. I recorded the video here: http://recordit.co/MrzQxy3BD0
PS: After debug Max's code, I found a problem is the custom post type was registered too early, before all the "init" hook, where Meta Box starts. So, that's might be the problem. I recommend checking the code again, make sure it looks like
add_action( 'init', 'my_register_post_type' );Anh Tran
KeymasterHi,
Thanks a lot for your comment! I've fixed the bug in the latest version. Please update.
Anh Tran
KeymasterI'm confused about "regular site page". The plugins allows you to:
- Create a settings page
- Create meta boxes and fields for that settings page
Both the steps requires you to put code within functions.php or plugin file. If you use MB Builder, then the Builder can help you do the 2nd step without copy and paste the code into functions.php file.
Anh Tran
KeymasterHi,
The settings page must be created using the method the plugin provides. The settings pages that created using normal Settings API are not supported. Because we can't hook into those settings page and show custom fields there.
Please follow this instruction to create settings pages. It's very similar to Settings API.
Anh Tran
KeymasterHi kesit,
You need to write custom code to move the data from custom fields to custom table. Here is a sample code:
$post_id = 1; $fields = ['field_1', 'field_2']; $table = 'your_custom_table'; $row = ['ID' => $post_id]; foreach ( $fields as $field ) { $row[$field] = get_post_meta( $post_id, $field, true ); } global $wpdb; $wpdb->insert( $table, $row );Anh Tran
KeymasterHi,
In the docs:
BLOB and TEXT columns also can be indexed, but a fixed length must be given. Make sure you set the length when you want to index a text column.
In your code, you make the
test_columnindexed, but it doesn't have a fixed length. So the code won't run. Change it to the following code will work:MB_Custom_Table_API::create( $wpdb->prefix.'data_khusus', array( 'test_column' => 'VARCHAR(20) NOT NULL', 'test_column2' => 'TEXT NOT NULL', ), array( 'test_column' ) );July 27, 2018 at 5:43 PM in reply to: ✅cant add metabox for custom post types with mb builder #10752Anh Tran
KeymasterHi,
How is the CPT registered? With
inithook and priority = 10?Anh Tran
KeymasterHi Dan,
The function
get_the_post_thumbnailhas a filterpost_thumbnail_htmlthat you can use to output the correct image:add_filter( 'post_thumbnail_html', function( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $gallery = rwmb_meta( 'field_id', array( 'size' => $size ), $post_id ); if ( empty( $gallery ) ) { return $html; } $image = reset( $gallery ); $html = wp_get_attachment_image( $image['id'], $size, false, $attr ); return $html; }, 10, 5 );Anh Tran
KeymasterHi Bernhard,
We've just updated the MB Geolocation which now support multiple autocomplete address fields. Please update and let me know how it goes.
Anh Tran
KeymasterHi Thomas,
That's the intended purpose. The color picker should act like a popup and should not change the height of the outer element (tab panel in this case). Because that might make the layout "dance" when we toggle the picker. And that's a bad experience if we're in a group.
Anh Tran
KeymasterHi Dan,
- The compatibility with WPML probably is better than Polylang. We have official support from WPML team, and they contributed code to Meta Box. Polylang follows WPML and supports the same thing as WPML does, so it's compatible.
- There's nothing special with WPML. Please just follow its documentation. I think one thing most people forget is the language configuration file. So, be sure you check it.
Cheers,
AnhAnh Tran
KeymasterHi Dan,
All the settings for admin columns are listed in the docs. And in the Builder, you can set the params using dot notation.
For example:
- If you just want to show the field in the admin column, set a custom attribute
admin_columnstotrue. - If you want to show the field before
namecolumn (like I did in the previous comment), set a custom attributeadmin_columnstobefore name. - If you want to show the field before
namecolumn and has a custom title "Featured Image", then use the dot notation to set a custom attributeadmin_columns.position' to 'before name', and another custom attributeadmin_columns.title' to "Featured Image".
Anh Tran
KeymasterHi Thomas,
I've just added
tab_default_activesetting in version 1.1.0. You just need to set'tab_default_active' => 'tab_id'in the meta box settings!July 26, 2018 at 11:25 AM in reply to: Get all field values into a public array and filter with page id in front end #10727Anh Tran
KeymasterHi,
Can you check if you register meta boxes under any condition such as
is_admin()or inside a hook? It's required to put the code that register meta boxes (add_filter('rwmb_meta_boxes', ...)) not inside any condition.The
rwmb_get_registryreturns a registry, e.g. a storage, of all registered meta box objects. You can use that registry to get all meta boxes viaget( 'all' )method.The statement:
$meta_boxes = rwmb_get_registry( 'meta_box' )->get( 'all' );actually means:
$meta_box_registry = rwmb_get_registry( 'meta_box' ); $meta_boxes = $meta_box_registry->get( 'all );To get meta values for a specific page ID, please use the 3rd parameter in the helper functions:
$value = rwmb_meta( 'field_id', '', $page_id );For more info, please read the docs.
-
AuthorPosts