Forum Replies Created
-
AuthorPosts
-
Long Nguyen
ModeratorHi,
In the loop, you can use the function the_permalink() to display the link to the post. See the example code https://docs.metabox.io/extensions/mb-relationships/#posts.
And to open the link in a new tab, you can add the attribute
target="_blank"to the<a>tag .<a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a>November 22, 2020 at 1:09 PM in reply to: ✅Using clonable field as param in pre_get_posts filter #22970Long Nguyen
ModeratorHi Hazmi,
The question relates to this topic https://support.metabox.io/topic/best-approach-when-it-comes-to-query-by-custom-field/.
I recommend using a single field or cloneable field with the setting
clone_as_multiple(not in a group). Why? Because the group is used for storing data, not for querying.See more in these articles:
https://metabox.io/introducing-clone-as-multiple-feature/
https://metabox.io/create-group-of-custom-fields-with-meta-box-group/#how-does-the-meta-box-group-save-dataLong Nguyen
ModeratorHi,
Thank you for your reporting. I'm going to create a feature request for the developer team change HTML <button> tag to <div> or <span> tag to cover this case.
November 21, 2020 at 8:32 AM in reply to: ✅best approach when it comes to query by custom field #22959Long Nguyen
ModeratorHi Brian,
As I said, the group is used for storing data (sub-fields value) not for querying by sub-fields value because the value of the group saved in the database is a serialized array. See more in https://metabox.io/create-group-of-custom-fields-with-meta-box-group/#how-does-the-meta-box-group-save-data.
This topic from StackOverFlow might help you to achieve your goal https://stackoverflow.com/questions/26364378/wp-query-when-meta-value-saved-as-serialized-array.
Long Nguyen
ModeratorHi,
The array key of image information is
full_url(underscore), notfull-url(hyphen). Can you please check it?Long Nguyen
ModeratorHi Mitchell,
The validation is being checked immediately after you click outside the input box. You can check more fields by adding more rules. One action name should be checked for one field ID.
'validation' => array( 'rules' => array( 'field_id1' => array( 'remote' => admin_url( 'admin-ajax.php?action={action_name1}' ), ), 'field_id2' => array( 'remote' => admin_url( 'admin-ajax.php?action={action_name2}' ), ), ), 'messages' => array( 'field_id1' => array( 'remote' => 'value is not passed', ), ) ),add_action( 'wp_ajax_{action_name1}', 'remote_validation' ); function remote_validation() { if( $_GET['field_id1'] === 'something' ) { echo "true"; //valid } else { echo "false"; //invalid } die(); }For more information, please follow the documentation
https://jqueryvalidation.org/remote-method/
https://www.sitepoint.com/jquery-ajax-validation-remote-rule/Note: validation remote seems does not work with Block Editor, please use the Classic Editor to use the custom validation. I will create a feature request for the developer team to support Block Editor.
Long Nguyen
ModeratorHi,
Yes, you have to pass the group ID to the function rwmb_get_field_settings(). It would be:
rwmb_get_field_settings( 'group' )To print the selected label of a select field (multi select) in a group, please use this code:
$group = rwmb_meta( 'group', ['storage_type' => 'custom_table', 'table' => 'custom'] ); $multi_select = isset( $group['language'] ) ? $group['language'] : ''; $group_settings = rwmb_get_field_settings( 'group' ); foreach ( $multi_select as $select_value ) { foreach ( $group_settings['fields'] as $field_settings ) { foreach ( $field_settings as $setting_key => $setting_value ) { if ( $setting_key == 'options' ) { echo $setting_value[$select_value]; } } } }Hint: You can use the code below to print out the structure of group settings then you will see what you need to create the code.
echo "<pre>"; print_r( $group_settings ); echo "</pre>";November 20, 2020 at 10:37 AM in reply to: ✅best approach when it comes to query by custom field #22947Long Nguyen
ModeratorHi,
The setting
clone_as_multipleworks with all cloneable fields in the default WordPress table (postmeta). If this setting is set to false, the cloneable groups will be saved in one row like{serialized array1, serialized array2 ...}If true, it will be saved in more rows like
{serialized array1} {serialized array2} ...And please notice that the group is used for storing data, not for querying.
November 20, 2020 at 10:29 AM in reply to: ✅setting a custom taxonomy term to file uploaded via advanced image field? #22946Long Nguyen
ModeratorHi,
The code works as well with the Meta Box fields, see my screen record https://share.getcloudapp.com/OAuWKRX6.
But you need to use some fields which upload the media via WordPress Media Library popup like the featured image such as
image_advanced,single_image,file_advanced.https://docs.metabox.io/fields/image-advanced/
https://docs.metabox.io/fields/single-image/
https://docs.metabox.io/fields/file-advanced/Long Nguyen
ModeratorHi,
You can clear the cache and run the command
composer installagain.rm -rf vendor && composer clear-cache && composer installhttps://docs.metabox.io/extensions/composer/#versions--updates
Follow the sample composer.json file to install all extensions https://github.com/wpmetabox/library/blob/master/composer/composer.json.
November 19, 2020 at 2:25 PM in reply to: ✅best approach when it comes to query by custom field #22920Long Nguyen
ModeratorHi Brian,
The field setting
clone_as_multipledoes not work with the custom table. It saves a serialized array in one cell like the group.
https://docs.metabox.io/extensions/mb-custom-table/#group-fieldsNovember 19, 2020 at 10:46 AM in reply to: ✅best approach when it comes to query by custom field #22910Long Nguyen
ModeratorHi Brian,
Query by subfield's value in a group is very difficult because the data saved is a serialized array. I recommend using the cloneable field and field setting
clone_as_multipleto get multiple date and query by its value.Follow this article for more information https://metabox.io/introducing-clone-as-multiple-feature/
Long Nguyen
ModeratorHi Eddie,
Please use the field ID for the first argument of the helper function. It might be
osm_kartefor your case.{{ mb.rwmb_meta( 'osm_karte', '', post.ID) }}Check the field ID in your code or in the Builder https://share.getcloudapp.com/E0u456BB.
Long Nguyen
ModeratorHi,
I'm going to create a feature request to support a filter hook to add classes for the submit button. At this time, please use the JS code to addClass for
#submitbutton.Long Nguyen
ModeratorHi Eddie,
The View does not support to show the map in the custom query, only show by using the PHP code. So you can use the helper function via the proxy
mb.:{% for post in relationships.veranstaltung_to_karte.from %} {{ post.osm_karte.latitude }},{{ post.osm_karte.longitude }} {{ mb.rwmb_meta( post.osm_karte, '', post.ID }} {% endfor %}For more information, please follow the documentation:
https://docs.metabox.io/extensions/mb-views/#running-php-functions
https://docs.metabox.io/fields/osm/#template-usage
https://docs.metabox.io/rwmb-meta/#arguments -
AuthorPosts