Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi Peter,
That's quite strange. I've just tried your code and all fields are showing up to me. Here is my screenshot:
https://imgur.elightup.com/55TiHeL.png
Can you check if those fields are not empty? Send me an email with a temporary admin account if you want me to look at the problem closer.
October 22, 2018 at 3:59 PM in reply to: ✅select advanced in Group showing: "Warning : Invalid argument supplied foreach" #11700Anh Tran
KeymasterHi Ale,
I've just checked the options for select_advanced field, looks like it's buggy when put in groups. I'll fix that.
Anh Tran
KeymasterHi Cornwall,
Looks like no boxes causes no data is saved, and thus generate errors when registering the CPT. Can you drop me an email with a temporary admin account to check?
Anh Tran
KeymasterHi Peter,
All fields in all meta boxes are merged and displayed in REST API responses. I see the link https://www.pdpa.co.uk/wp-json/wp/v2/events shows some fields. Can you check that fields come from all meta boxes?
In case there are some fields are missing, please check your code that registers meta boxes. Make sure there's no conditions like:
if ( is_admin() ) { // Or any similar condition add_filter( 'rwmb_meta_boxes', 'your_meta_boxes' ); }Anh Tran
KeymasterHi Juanita,
Did you save the post after reordering the relationships? The plugin relationship values in the exact order they're set in the backend. In the frontend, they're sorted by the
IDcolumns frommb_relationshipstable. This is the query looks like in the plugin's code:Anh Tran
KeymasterHi,
Have you created any meta box (with custom fields) for that settings page? In our documentation, there are 2 steps:
- Creating a settings page
- Creating settings fields for that settings page
Make sure that you did both of them.
October 20, 2018 at 8:31 AM in reply to: ✅select advanced in Group showing: "Warning : Invalid argument supplied foreach" #11686Anh Tran
KeymasterHi Ale,
You're calling the field
cellclasses, which is a sub-field of a groupstyle. So the functionrwmb_metareturns nothing, thus the nextforeachloop doesn't work.You should get the value of the group
stylefirst, then get the value of sub-field. Like this:$style = rwmb_meta( 'style' ); $cell_classes = isset( $style['cellclasses'] ) ? $style['cellclasses'] : array(); foreach ( $cell_classes as $cell_class ) { echo $cell_class; }Anh Tran
KeymasterHi Huy,
Your code has a PHP error and can't work. The function
ptdoesn't understand the variable$pricing.I have rewritten your code as follows, please try it:
// Sub function function pt( $pricing ) { $table = isset( $pricing['pricing_table_id'] ) ? $pricing['pricing_table_id'] : ''; if ( ! $table ) { return; } $plans = rwmb_meta( 'plan', '', $table ); if ( empty( $plans ) ) { return; } foreach ($plans as $plan) { $name = isset( $plan['plan_name'] ) ? $plan['plan_name'] : ''; echo $name; } } //Main function function page_section() { $sections = rwmb_meta( 'section' ); if ( ! empty( $sections ) ) { return; } foreach ( $sections as $section ) { if ( empty( $section['section_pricing'] ) { continue; } $pricing = $section['section_pricing']; pt( $pricing ); } }Anh Tran
KeymasterHi Vadym,
I see you're using Gutenberg. This editor saves custom fields via ajax calls. So, can you try waiting for 1-2 seconds after post is saved, just to make sure the custom fields's ajax call is finished, and check the data again?
October 20, 2018 at 8:18 AM in reply to: ✅pre_get_posts to get all posts connected to single object #11683Anh Tran
KeymasterHi Juanita,
The
parse_queryhook runs just beforepre_get_postsand there's nothing between them. See this screenshot:https://imgur.elightup.com/CtLBCui.png
So, if your code works with
pre_get_posts, it should work withparse_query. I guess the problem might come from other things.Anh Tran
KeymasterHi Purdue,
All types should use text or equivalent type for storing the data. So
TEXT NOT NULLis the general type.But if your data is short, or you want to tell MySQL to index the field (e.g., making the field a key), then you should use
VARCHAR(length) NOT NULL. MySQL can't index a text field without knowing its max length.Anh Tran
Keymaster@Ale: No, it's not. Gutenberg is JavaScript-editor and it doesn't support many PHP hooks, including contexts.
October 18, 2018 at 4:36 PM in reply to: ✅pre_get_posts to get all posts connected to single object #11659Anh Tran
KeymasterHi Juanita,
You're right about the query var. And your idea of adding the query var is great. I think the only problem is using
pre_get_postsis too late. The plugin usesparse_queryhook to setup some parameter for the SQL. So you might want to change your code frompre_get_poststoparse_query.Anh Tran
KeymasterHi Vadym,
Can you take a screenshot of the edit screen with all questions and answers?
Anh Tran
KeymasterHi Cornwall,
Can you enable debugging and see if there's any PHP error on the "New Post Type" screen?
-
AuthorPosts