Forum Replies Created
-
AuthorPosts
-
Long Nguyen
ModeratorHi,
You need to check the field value before creating a new post in the admin area. If the field has no value at the first load and post title is set with an empty value, it happens the error
WordPress database error:: [Column 'post_title' cannot be null].function iswp_update_company_title( $data ) { if( $data['post_type'] == 'company' ) { // Check post type if( isset( $_POST['company-name'] ) ) { $title = $_POST['company-name']; $slug = sanitize_title_with_dashes( $title,'','save' ); $slugsan = sanitize_title( $slug ); $data['post_title'] = $title ; //Updates the post title to your new title. $data['post_name'] = $slugsan; //Updates the post name aka slug to sanitized version of title. } } return $data; // Returns the modified data. } add_filter( 'wp_insert_post_data' , 'iswp_update_company_title');Long Nguyen
ModeratorHi there,
Please make sure that you pass the correct meta box ID to the shortcode.
[mb_user_profile_info id="meta-box-id"]You can get the meta box ID with the Builder https://share.getcloudapp.com/Blu57Xd8
or add to the codeadd_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $meta_boxes[] = array( 'title' => 'Contact Info', 'type' => 'user', 'id' => 'user-meta-box', // meta box ID 'fields' => array( ... ), ); return $meta_boxes; } );July 25, 2020 at 12:17 PM in reply to: Field Type: post - filter query args by external fields #20962Long Nguyen
ModeratorHi Austin,
I'm going to create a feature request and discuss it with the developer team to support more options for the relationship.
Thank you and have a nice day.
July 25, 2020 at 9:41 AM in reply to: ✅Plugin rejected by WP team because of duplicate copy of clipboard.min.js #20961Long Nguyen
ModeratorHi,
Thank you for reaching out.
I'm going to discuss with the developer team to take a look at the option copy code when creating the post type, taxonomy to support other plugins submitted to WordPress.org.
Long Nguyen
ModeratorHi,
Each view is a template, you can include to another view then use the declared variable in that view.
{% include 'view-name' %}Please follow this article for more information https://metabox.io/mb-views-creating-including-template-parts/.
Long Nguyen
ModeratorHi Will,
You can follow this documentation to create the field
postand add the setting'multiple' => trueto select multiple posts.
https://docs.metabox.io/fields/post/'fields' => array( array ( 'id' => $prefix . 'post', 'type' => 'post', 'name' => esc_html__( 'Post', 'text-domain' ), 'post_type' => 'page' 'field_type' => 'select_advanced', 'multiple' => true, ), )screenshot in MB Builder https://share.getcloudapp.com/6qu2dN68.
Long Nguyen
ModeratorHi,
The function
get_posts()works perfectly if you are going to use a custom query that doesn't need pagination. If you want to show the pagination, please useWP_Queryvia PHP code to show it.Please follow the documentation for more information https://developer.wordpress.org/reference/functions/paginate_links/#user-contributed-notes.
July 24, 2020 at 10:01 AM in reply to: Field Type: post - filter query args by external fields #20949Long Nguyen
ModeratorHi Austin,
We have the extension MB Relationships which can help you to cover your case. It's free so you can try to create the relationship between post types and filter posts by WP_Query.
Follow this documentation for more information https://docs.metabox.io/extensions/mb-relationships/.
Long Nguyen
ModeratorHi,
You can create a shortcode then add to the Beaver Themer to show the field value in a group field.
Here is my sample code
function group_field() { $group_field = rwmb_meta( 'group_field' ); return $group_field['text_field']; } add_shortcode( 'group_field', 'group_field' );and screen record to demo https://www.loom.com/share/717feea1c46d41838e01d90f42a05818
Follow the documentation to get the sub-field value
https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-value
and create the shortcode
https://codex.wordpress.org/Shortcode_APILong Nguyen
ModeratorHi Mark,
You can use the function
query_posts()or create a new instance WP_Query in the archive template file of the theme with the argumentsorderbyandmeta_keyto sort the post in the archive page by the field number value.query_posts( array( 'order' => 'DESC', 'meta_key' => 'field_id', 'orderby' => 'meta_value_num', //or 'meta_value_num' ) );$args = array( 'post_type' => 'post', 'orderby' => 'meta_value_num', 'meta_key' => 'field_id', ); $query = new WP_Query( $args );and display the field value of each post by using the helper function
rwmb_metain the template parts file.For more information, please follow the documentation.
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
https://developer.wordpress.org/reference/functions/query_posts/
https://wordpress.stackexchange.com/questions/15477/custom-query-with-orderby-meta-value-of-custom-fieldJuly 23, 2020 at 4:48 PM in reply to: ✅Add New Items to Taxonomy creates inconsistent results #20932Long Nguyen
ModeratorHi,
Could you please check the taxonomy slug
authoragain? I've tested your code on my local site, and the Add new button display on two taxonomy selects as well.July 23, 2020 at 4:28 PM in reply to: ✅Google Maps using default API key MB Settings Page with MB Groups #20931Long Nguyen
ModeratorHi,
You can use the second parameter
$argsto pass the API key to the map.$group_values = rwmb_meta( 'group_id' ); $args = array( 'api_key' => 'your-API-key' ); // If group is cloneable foreach ( $group_values as $group_value ) { echo RWMB_Map_Field::render_map( $group_value['map_id'], $args ); }Let me know how it goes.
Long Nguyen
Moderator@hartsook
You need to add the default content for the field
wysiwygand set the value for the 'content' custom field. For your case, the code would be https://pastebin.com/erjmfhht.Remember change the post to your post type and follow the code in the documentation https://docs.metabox.io/save-wysiwyg-content-post-content/.
Long Nguyen
ModeratorHi Luke,
The main purpose of the block editor is a block display in the backend like in the frontend. So if you enqueue to load a file style.css for the specific block, it loads in both backend and frontend.
See my screenshots
https://share.getcloudapp.com/yAuYde5J
https://share.getcloudapp.com/KouBp8obYou can create the block by using the example files https://docs.metabox.io/extensions/mb-blocks/#example.
July 23, 2020 at 9:42 AM in reply to: ✅Google Maps using default API key MB Settings Page with MB Groups #20925Long Nguyen
ModeratorHi,
That means you are using a script code on the front end and it has another Google API key? The field Google Map only takes the API key in the field settings base on our design. You can add more libraries via filter
rwmb_google_maps_url. See more in the documentation
https://docs.metabox.io/fields/map/#filters
https://developers.google.com/maps/documentation/javascript/libraries -
AuthorPosts