Forum Replies Created
-
AuthorPosts
-
October 20, 2018 at 8:18 AM in reply to: ✅pre_get_posts to get all posts connected to single object #11683
Anh 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?
Anh Tran
KeymasterFor better organization, I put each module in separate files which are located in different folder.
This is great and is a recommended way to organizing fields. I also wrote about this.
Problem is value in fields cannot be retrieved, all none whilst html output is OK.
Can you provide more details on how you retrieve values? Code is appreciated.
Anh Tran
KeymasterHi,
The datetime fields doesn't do validation for the format. It's kind of a bug in jQueryUI datepicker. I'd suggest setting the field
readonlyto prevent users entering values in wrong format.October 18, 2018 at 3:03 PM in reply to: ✅MB Revisions in combination with MB Custom Table and Custom Post Type #11654Anh Tran
KeymasterHi Purdue,
I've just pushed an update for both MB Revision and MB Custom Table. Now they work well together and you can use them to track revisions for CPT in custom tables. Please update and let me know if you find any problem.
Anh Tran
KeymasterHave you resolved this? Do you need any further help?
Anh Tran
KeymasterHi,
When I unserialize the value, I see questions and answers are saved correctly:
https://www.unserialize.com/s/54991f6e-ab47-be68-7bdc-00006081513b
FYI, the group extension saves all sub-field values in a serialized array in the database (which is what you just saw). When you get the value, it will be unserialized and returns an array.
Anh Tran
KeymasterHi Cornwall,
The MB Custom Post Type plugin creates only custom post types. No meta boxes or custom fields are created with it. To create meta boxes or custom fields, you'll need MB Builder.
Anh Tran
KeymasterI see, it's much clearer now.
To get the field values from your table CPT, please pass the post ID (value of the field
pricing_table_id) to the 3rd parameter ofrwmb_metafunction. Here is a modified version of your initial code:$table = isset( $pricing['pricing_table_id'] ) ? $pricing['pricing_table_id'] : ''; if ( $table ) { $plans = rwmb_meta( 'plan', '', $table ); // THIS if ( ! empty( $plans ) ) { foreach ($plans as $plan) { $name = isset( $plan['plan_name'] ) ? $plan['plan_name'] : ''; echo $name; } } }Anh Tran
KeymasterHi Huy,
To the the current post object, please use:
$post = get_post();To get fields, just use
rwmb_meta(). But I think you already know that.I'm not sure what your problem is. Can you provide more details and the setup code of meta box, so I can give more useful instruction?
Anh Tran
KeymasterHi Dan,
Unfortunately, creating setting page requires coding. It's just 10 lines of code and you can go to Appearance > Editors to add them into your theme's
functions.phpfile.Then you can use the MB Builder to create fields for settings page using GUI and finally use BB Themer to get the settings and show them on the front end.
-
AuthorPosts