Forum Replies Created
-
AuthorPosts
-
April 28, 2022 at 10:27 PM in reply to: ✅Connecting Child Posts to a Parent Post Automatically. #35819
Long Nguyen
ModeratorHi,
You can add the custom PHP code to the file functions.php in the theme/child theme folder or in a custom plugin or use Code Snippets plugin https://wordpress.org/plugins/code-snippets/
Long Nguyen
ModeratorHi,
There is an issue with the setting
query_argsof the relationship, it is fixed in this commit https://github.com/wpmetabox/mb-relationships/commit/7e9505be0b3fc2ac69a1fc1ffba714cb4ede41f8You can download this branch to your site and follow the documentation to use the query_args with coding
https://docs.metabox.io/extensions/mb-relationships/#using-codeMB_Relationships_API::register( [ 'id' => 'job-to-post', 'from' => [ 'object_type' => 'post', 'post_type' => 'job', 'field' => [ 'query_args' => [ 'orderby' => 'title', 'order' => 'ASC' ] ] ], 'to' => [ 'object_type' => 'post', 'post_type' => 'post', 'field' => [ 'query_args' => [ 'orderby' => 'title' ] ] ], ] );April 28, 2022 at 9:25 PM in reply to: How to get PO file use Loco Translate with Label and Description field Metabox #35817Long Nguyen
ModeratorHi,
Loco Translate can help you to scan the translatable text and add it to the PO file, check this screen record https://monosnap.com/file/4w7oyBOzMsqKfxmyMKopsyBSuQOBYx
Long Nguyen
ModeratorHi,
I think you can check if the variable
$modelIdis not empty and then create the relationship.private function create_relationship(String $yearId, String $modelId): bool { if( !empty( $modelId ) ) { return \MB_Relationships_API::add($yearId, $modelId, 'yearModel', 1, 1); } return false; }Or follow this topic to check if a post existed by ID https://stackoverflow.com/questions/9638375/check-existence-of-a-post-by-id-in-wordpress
Long Nguyen
ModeratorHi,
If you create a custom query (loop) in the View, you can use the helper function
rwmb_meta()or click on the field name in the Insert Fields tab to get the field value. See this screenshot https://monosnap.com/file/m6icy7DSacrLey0boxiUkUIFU7kJ4IAnd please notice that the
post_titleis not a custom field created by Meta Box, it is a property of the Post object so you can just usepost.post_titleto get the post title.Please read more on this documentation https://docs.metabox.io/extensions/mb-views/#custom-query
April 28, 2022 at 12:17 PM in reply to: ✅autofill a select custom field with a custom field from another group. #35811Long Nguyen
ModeratorHi,
Yes, you can use the callback function to create dynamic options for the select field. But the options will be parsed on load, not "live" (realtime update) as JS does.
April 28, 2022 at 12:15 PM in reply to: ✅Connecting Child Posts to a Parent Post Automatically. #35810Long Nguyen
ModeratorHi,
You can create a button with a link to the page that has the frontend form, and pass the Project A post ID to the URL via a custom parameter. Like this
http://your-site.com/frontend-submission-page/?current_post_id=get_queried_object_id()Then retrieve the project ID via the variable $_GET
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { $project_id = $_GET['current_post_id']; if( !empty( $project_id ) ) MB_Relationships_API::add( $project_id, $post_id, 'your-relationship-ID', $order_from = 1, $order_to = 1 ); }, 10, 2 );Hope that makes sense.
Long Nguyen
ModeratorHi,
You can try to follow this tutorial to increase the PHP setting
max_input_varsto fix the issue
https://metabox.io/wordpress-custom-fields-not-saving-increase-max-input-vars/Let me know how it goes.
Long Nguyen
ModeratorHi,
No need to use the function do_action() in your code, just see the examples below to hook a callback function to the action.
You can also read more on this documentation to know how to use the action hook https://developer.wordpress.org/plugins/hooks/actions/
April 26, 2022 at 10:21 PM in reply to: ✅Connecting Child Posts to a Parent Post Automatically. #35799Long Nguyen
ModeratorHi,
For example: you have a post Project A and a frontend submission form on that post page, then you want to create a post Entry B when submitting the frontend form and connected to the post Project A automatically.
If yes, you can use this custom code
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { MB_Relationships_API::add( get_queried_object_id(), $post_id, 'your-relationship-ID', $order_from = 1, $order_to = 1 ); }, 10, 2 );Refer to this topic https://support.metabox.io/topic/auto-relationship-on-form-submission/#post-31334
Long Nguyen
ModeratorHi Chris,
You can use the WordPress function
get_the_ID()to get the post ID in the loop, and use the helper functionrwmb_meta()to get the field value based on the post ID. Remember to use the view Type: Shortcode and add the shortcode to the loop. For example:{% set post_id = mb.get_the_ID() %} PostID: {{ post_id }} Field value: {{ mb.rwmb_meta( 'my-field-id', '', post_id ) }}Please read more on the documentation
https://docs.metabox.io/extensions/mb-views/#custom-query
https://developer.wordpress.org/reference/functions/get_the_id/April 26, 2022 at 9:59 PM in reply to: ✅autofill a select custom field with a custom field from another group. #35797Long Nguyen
ModeratorHi Fernando,
This case is beyond the scope of support of Meta Box. Meta Box does not support populating a field value based on another field value. You can use JS code with AJAX to update the select options.
April 26, 2022 at 9:37 PM in reply to: Having major DB crashing issue after updating to 5.6.3 #35796Long Nguyen
ModeratorHi Sam,
It looks like there is no space left in the database. Can you please re-check this?
And please make sure that you have the latest version of Meta Box 5.6.3, MB AIO 1.15.8 on your site then deactivate all plugins except Meta Box, MB AIO and switch to the standard theme of WordPress (Twent TwentyTwo) to troubleshoot the issue.April 25, 2022 at 10:12 PM in reply to: ✅How to make a post of a CPT sticky in DASHBOARD (not frontend)? #35787Long Nguyen
ModeratorHi,
It is beyond the scope of support of Meta Box, you can follow this topic to use the code to stick a post in the backend.
https://wordpress.stackexchange.com/questions/167360/how-to-make-post-sticky-in-the-admin-pageApril 25, 2022 at 10:09 PM in reply to: How to get PO file use Loco Translate with Label and Description field Metabox #35786Long Nguyen
ModeratorHi,
If you are using the builder to create the custom fields, you can get the PHP code and put the code to the file functions.php in the theme/child theme folder to register the custom fields by coding then translate the field name and field description.
https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code -
AuthorPosts