Forum Replies Created
-
AuthorPosts
-
Long Nguyen
ModeratorHi Brian,
Parsing a shortcode in the URL is very complicated. It's very easy if you modify your code like this
<a href="https://demo.com/?your_parameter=<?php echo do_shortcode('[rwmb_meta id="tour_date"]') . do_shortcode('[rwmb_meta id="tour_name"]') ?>">Button</a>This piece of code will help you to parse the shortcode in the URL when clicking to the button, but only one shortcode will be parsed.
https://demo.com/?your_parameter=[rwmb_meta id="tour_date"]You can use Code Snippet to run the code and you need to find the class of the button to put on the code.
April 3, 2020 at 7:54 AM in reply to: ✅Trouble getting file url of file attachment in cloneable group #18828Long Nguyen
ModeratorHi,
Please take a look at my screen record.
The fields do not have any value but after clicking Publish, the table still shows as well as the button download above. Remove attribute
stateor set tofalsethen refresh and update the product again to see the result.Long Nguyen
ModeratorHi,
Unfortunately, the plugin Meta Box does not support to check/validate the value in a field is unique or not. But you can use the post ID of WordPress itself (unique) to concatenate with your field value when printing out on the front end
echo rwmb_meta('field_id') . get_queried_object_id();April 2, 2020 at 10:05 AM in reply to: ✅Trouble getting file url of file attachment in cloneable group #18814Long Nguyen
ModeratorHi,
Because you've enabled the attribute
save_stateso the file attachments always return an array$file_attachments = rwmb_meta( 'file_attachments' );This attribute means when you add more groups but not put any name or file, it will save the last state when publishing the product. Take a look at my screenshot https://cl.ly/e883f5d356f2
Change the attribute
'save_state' => falseand refresh your site, the button will not display if there are empty fields in the first group.Long Nguyen
ModeratorHi Brian,
If you are using the shortcode outside the loop (or the post), you should add the second attribute
object_idthen the shortcode should be[rwmb_meta id="field_id" object_id="post_id"]you can find the post ID in the URL when editing the post
For further information, please follow our documentation
https://docs.metabox.io/shortcode/Long Nguyen
ModeratorIf you use the field as the excerpt, please change the ID of the field to
excerptinstead ofcontent, take a look at my screenshotLong Nguyen
ModeratorHi Nuno,
WordPress supports to export the custom post type by going to Admin Dashboard -> Tools -> Export -> Post types
Long Nguyen
ModeratorSo strange, on my local site the field
textareadisplay as well asWYSIWYG
https://cl.ly/66366ab23a1a
https://cl.ly/69ac21a36317After changing the position of the field, please try to clear the cache and check the field again.
Long Nguyen
ModeratorHi B,
The field can work any position before or after title, content. As I can see in your first and second images, the field is
WYSIWYGtype but the third istextareatype. Could you please check it out?Long Nguyen
ModeratorThe password, in essential, that means remember not to store in a field. These articles maybe help you to secure the argument
https://blog.httpwatch.com/2009/02/20/how-secure-are-query-strings-over-https/
https://fastspring.com/docs/passing-sensitive-data-with-secure-requests/Long Nguyen
ModeratorHi Johann,
WordPress 5.4 introduces the new hook to add custom fields to the menu item, we are discussing and researching for this feature in the future update.
Keep this plugin up to date and you will have more control over your site.
Long Nguyen
ModeratorHi,
A password after saving to the database, it is hashed and can only be checked by the function.
https://codex.wordpress.org/Function_Reference/wp_hash_passwordSo if you want to save the API password, it should be a Text field with a string then you can send this string when connecting to API as an argument.
March 31, 2020 at 10:58 AM in reply to: ✅get the value of a custom field from a cpt when not using "the loop" #18771Long Nguyen
ModeratorI have a CPT name Customer File and create three text fields (number, address, phone) as the code below
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = array ( 'title' => esc_html__( 'Customer info', 'text-domain' ), 'id' => 'customer-info', 'post_types' => array( 0 => 'customer-file', ), 'context' => 'normal', 'priority' => 'high', 'fields' => array( array ( 'id' => $prefix . 'name', 'type' => 'text', 'name' => esc_html__( 'Name', 'text-domain' ), ), array ( 'id' => $prefix . 'address', 'type' => 'text', 'name' => esc_html__( 'Address', 'text-domain' ), ), array ( 'id' => $prefix . 'phone', 'type' => 'text', 'name' => esc_html__( 'Phone', 'text-domain' ), ), ), ); return $meta_boxes; }then use this code to show the list invoices and the customers name
$invoices = array( array( 'customernumber' => '101', 'invoicenumber' => 1, 'invoiceamount' => 100 ), array( 'customernumber' => '213', 'invoicenumber' => 2, 'invoiceamount' => 95 ), array( 'customernumber' => '107', 'invoicenumber' => 3, 'invoiceamount' => 107 ) ); $args = array( 'post_type' => 'customer-file', 'post_status' => 'publish', 'posts_per_page' => -1, ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); foreach ( $invoices as $number => $invoice ) { if( $invoice['customernumber'] == $loop->post->post_title ) { echo 'Customer Number: ' . $invoice['customernumber'] . '<br>'; echo 'Invoice Number: ' . $invoice['invoicenumber'] . '<br>'; echo 'Invoice Amount: ' . $invoice['invoiceamount'] . '<br>'; echo 'Name: ' . rwmb_meta( 'name' ) . '<br>'; echo 'Address: ' . rwmb_meta( 'address' ) . '<br>'; echo 'Phone: ' . rwmb_meta( 'phone' ) . '<br>'; } } endwhile; wp_reset_postdata();Please see my screen record to make sense https://cl.ly/3fd58b9a803b
March 31, 2020 at 8:41 AM in reply to: ✅get the value of a custom field from a cpt when not using "the loop" #18765Long Nguyen
ModeratorHi James,
Could you please share the structure of the Invoices array? Assume that the invoices return the array like this and you can use the for loop to get the name of the customer
$invoices = array( array( 'name' => 'John', 'price' => 10 ), array( 'name' => 'Marry', 'price' => 20 ), array( 'name' => 'Doe', 'price' => 30 ) ); foreach ( $invoices as $number => $invoice ) { if( $invoice['name'] == $your_query->post->post_title /*John*/ ) { echo 'the price is: ' . $invoice['price']; // echo rwmb_meta('your_field_id'); } }Long Nguyen
Moderator -
AuthorPosts