Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi David,
Thanks a lot for your examples. That makes the picture a lot clearer. I will read more about this (probably Posts 2 Posts is the best one in WP ecosystem, right?). In the mean time, would you mind sharing how you have implemented a solution before?
Anh Tran
KeymasterHi David,
Thanks for a great question.
Currently, the way Meta Box and extensions work are one-way relationship. You can use a field "post" to attach 1 or many posts to a post. That's similar to 1-1 and 1-many relationship, but just one way.
The MB Custom Table does the storing job only. So if you create a custom table with 2 columns ID and related_posts, you can store related posts for a single post. And you can query the related posts via helper functions.
I've been thinking about relationship, but I'm not too clear about the usage of that in the situation of WordPress. Would you mind describe what you need and let's work on a good solution?
Anh Tran
KeymasterGreat! Happy holidays ๐
Anh Tran
KeymasterHi, can you please give me more info about the "dynamic options"? And the clone ID you're talking about is the ID of inputs in the group?
Anh Tran
KeymasterI've found the bug and fixed it in version 1.2.12 of Group extension. Please update.
December 6, 2017 at 8:40 AM in reply to: โ Refresehing the whole WP Admin Panel after settings saved #7767Anh Tran
KeymasterHi G.,
I guess I understand your point. Probably the code that saves data happens after your code that hides menus, metaboxes, etc. Would you please post your code here so I can debug that?
Anh Tran
KeymasterHi,
For your needs, the
image_selectfield seems to be the suitable field type. However, it doesn't have the pagination or search feature. To do that, I think you need to write a custom code using a filter library like ListJS (there are probably more libraries).You can hook to
rwmb_enqueue_scriptsaction to enqueue your JS like this:add_action( 'rwmb_enqueue_scripts', function() { wp_enqueue_style( 'listjs', 'URL here' ); wp_enqueue_script( 'listjs', 'URL here' ); wp_enqueue_script( 'your-js', 'URL here' ); } );And in your JS file, you can write the JS that does the filtering or searching.
Anh Tran
KeymasterHi,
Looks like you're using cloneable groups. For each value of a group, please check the existence of sub-fields, like this:
$title = isset( $item_item_item['title'] ) ? $item_item_item['title'] : ''; echo $title;Anh Tran
KeymasterHi,
I think hooking to
wp_insert_post_datais too generic as it fires every time a post is added/updated.The extension already have 2 filters that you can use to change the post data when saving:
rwmb_frontend_update_post_datafor updating posts andrwmb_frontend_insert_post_datafor creating new posts. Previously it has only 1 params: the submitted post data. But I've just updated the extension, adding 2nd parameter: the shortcode params, so you can use to check whether you are on the right meta box.This is sample code:
add_filter( 'rwmb_frontend_insert_post_data', 'your_function', 10, 2 ); add_filter( 'rwmb_frontend_update_post_data', 'your_function', 10, 2 ); function your_function( $data, $config ) { if ( $config['id'] !== 'your_meta_box_id' ) { return $data; } // Your code to get post_title $data['post_title'] = ...; return $data; }Please try it and let me know if you need anything. I can update the extension to make it works for you.
Anh Tran
KeymasterHi, I see the bug. I'm debugging it and will fix it as soon as I can.
Anh Tran
KeymasterHi Hazmi,
Regarding the 1st problem, can you please describe steps to replicate it? I couldn't replicate on my side. But my guess is the saved value in the DB. If you already saved values of your fields into an option, then when you add a new field which has name already registered before, then the value might be taken from the previous one. Not sure if that's the case, but you can try remove the option in the DB and try again.
Regarding the problem with QTag, do you have any wysiwyg field in your settings page? QTags is available only for the editor. With the code above, I can't see anything in the console:
Anh Tran
KeymasterHi,
I've just fixed it on Github. The error message now will display below the inputs. Can you please try it?
Anh Tran
KeymasterHi,
I've just tried your code and this is my screenshot:
Can you guys post the code that includes the heading field?
Anh Tran
KeymasterHi, I've fixed this bug on Github. Can you please try it?
PS: My previous reply was for the PHP warning that you posted. Sorry for misunderstanding.
-
AuthorPosts