Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi William,
Thanks for using Meta Box!
Your question is an advanced question, and it's quite complicated since it relates to WordPress Rewrite API. Our plugins don't handle that work. However, you can find some solution on the internet. Here are some of them:
https://wisdmlabs.com/blog/add-taxonomy-term-custom-post-permalinks-wordpress/
https://wordpress.stackexchange.com/questions/49141/rewriting-a-custom-post-type-permalink-with-taxonomy-term
https://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-postAnh Tran
KeymasterHi Toomas,
I'm afraid I haven't seen any site or plugin doing this. The only way I can think of is using a custom code. But I don't have any sample at the moment.
April 27, 2019 at 10:21 AM in reply to: ✅Same metabox fields in diferents CPT and diferents Custom Tables #14312Anh Tran
KeymasterHi,
I think to remove the duplicated code, you can store all the fields in a variable
$fieldsand set it for 2 meta boxes (each for each post type):add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $fields = []; // your fields $meta_boxes[] = [ 'post_types' => 'post_type_1', 'custom_table' => 'table_1', 'fields' => $fields, ]; $meta_boxes[] = [ 'post_types' => 'post_type_1', 'custom_table' => 'table_1', 'fields' => $fields, ]; return $meta_boxes; } );That way, you don't have to repeat a large part of code. Also see this tutorial.
April 27, 2019 at 10:15 AM in reply to: change the name of the pdf file name that is displayed on front end #14311Anh Tran
KeymasterHi Brian,
- Was that correct to do?
Yes! Sorry, my mistake. I missed the "s".
- How do you use Meta Box shortcodes to output group fields?
The shortcode only outputs list of data of sub-fields in a group. I'd not recommend using it for groups. Instead, write your own shortcode, like what you did with
group_monthly_calendarshortcode.- Yes it was in the field. But now since I changed it to be in a group I don’t know what the ID would be to test again.
As you need to get the PDF file URL, try modifying your shortcode to this:
add_shortcode( 'group_monthly_calendar_pdf_url', function( $atts ) { $output = ''; $group = rwmb_meta( 'group_cal_pdf' ); $file_ids = isset( $group['cal_pdf'] ) ? $group['cal_pdf'] : null; $file_id = empty( $file_ids ) ? null : reset( $file_ids ); $file = RWMB_File_Field::file_info( $file_id ); if ( is_array( $file ) ) { return $file['url']; } return ''; } );- Are you having issues saving settings in the Group Field in MB Builder?
I see. Thanks a lot for your video. I'll check and fix it.
- File Advanced showing “max number of files” even though I did not select the “show status” check box.
Thanks. Let me check and fix it.
- If you remove the “Label” for the Group field – but then you add a “Group title text” it seems like that should then show up where the normal “Label” field showed. Currently all my “group” fields are blank. See the above video link.
I see. Thanks a lot for your video. I'll check and fix it.
April 25, 2019 at 10:40 AM in reply to: ✅Open Street Map: error display when 'marker_icon' is activated #14275Anh Tran
KeymasterHi Toomas,
Unfortunately, it's not possible with the plugin.
Anh Tran
KeymasterWhich PHP version are you using? I'm writing in PHP 5.4 (that accepts short array syntax). Please upgrade if you're using lower PHP version.
Anh Tran
KeymasterPlease try this:
jQuery(document).ready(function( $ ){ $('.count input').attr('readonly', true); $('.radio').change(function () { // Counting. var count=0; $('.radio input:checked').each(function(){ if ($(this).val().replace(/V_/g,'')=="Specialiteit") { count += 1; } }); $('.count input').val(count); var $submitButton = $( '.rwmb-form-submit' ).children( 'button' ); if ( count > 3 ) { $submitButton.prop( 'disabled', true ); } else { $submitButton.prop( 'disabled', false ); } }); });April 25, 2019 at 10:23 AM in reply to: ✅Can't Get Image Field to Display Image via Shortcode #14270Anh Tran
KeymasterGreat video, Mark!
Can you try again with
rwmb_metashortcode and the latest version of Meta Box on Github? I pushed a fix for the shortcode to get the correct post ID from the loop inside another page.Not sure why BB's shortcode not working. Let me check that.
April 25, 2019 at 10:16 AM in reply to: Taxonomy Field With Type Select Advanced Broken in Gutenberg Editor #14269Anh Tran
KeymasterHi, I've just checked and can't replicate the bug:
https://imgur.elightup.com/VGrQIH1.png
Can you try with no plugins activated and with normal
post?April 25, 2019 at 10:10 AM in reply to: change the name of the pdf file name that is displayed on front end #14268Anh Tran
KeymasterHi Brian,
Thanks for the detailed reply! Ok slowly learning. For the first two snippets you provided. I’m not using a template file. I’d like to incorporate it into a shortcode in my functions.php file and then just use the shortcode to output those added values? Is that possible / what would that look like?
Yes, of course. Here is the modified code for the 1st snippet:
add_shortcode( 'your_shortcode', function( $atts ) { $output = ''; $file = rwmb_meta( 'my_file' ); $file = empty( $file ) ? null : reset( $file ); // Just get the first file. $title = rwmb_meta( 'my_file_title' ); if ( is_array( $file ) ) { $output .= "<a href='{$file['url']}'>{$title}</a>"; } return $output; } );But the link it generated was for the exact same page I was on. Not the pdf link? Not sure what went wrong there.
Can you check if the current page has PDF file in the
my_filefield?April 25, 2019 at 10:05 AM in reply to: ✅rwmb_my_custom_field_after_save_field can't update my own fields in the database #14267Anh Tran
KeymasterHi Sergio,
Did you try:
add_action( 'rwmb_field_A_after_save_field', function ( $null, $field, $new, $old, $object_id ) { $storage = $field['storage']; $storage->update( $object_id, 'field_B', 'new value' ); }, 10, 5 );This code works only when the field A is put after field B in the meta box, which means field B is already saved.
If field A is before field B, then after we run this code, field B still use value from the submission. In this case, please try this code:
add_action( 'rwmb_field_A_after_save_field', function ( $null, $field, $new, $old, $object_id ) { $_POST['field_B'] = 'new value'; // Modify directly submitted value from $_POST. }, 10, 5 );Anh Tran
KeymasterHi Christopher,
The sub-fields inside groups are not run through filters. Only the filter for the top-level group is used.
So, please use the filter of the top-level group and modify the value of the sub-fields.
Anh Tran
KeymasterHi Sergio,
I guess you're using another plugin that also enqueues Google Maps. The URL above is different from what Meta Box outputs. If that's correct, it's easy to explain 2 errors in the console: the API key is not provided and the limit exceeds.
Anh Tran
KeymasterHi Sergo,
The Open Street Map field is per post. If you need to display all location of all posts on a same map, you might need to write custom code. I'll make a tutorial about that later in the blog. Stay tuned.
-
AuthorPosts