Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1,711 through 1,725 (of 3,708 total)
  • Author
    Posts
  • in reply to: pre_get_posts to get all posts connected to single object #11683
    Anh TranAnh Tran
    Keymaster

    Hi Juanita,

    The parse_query hook runs just before pre_get_posts and 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 with parse_query. I guess the problem might come from other things.

    in reply to: Data types for MB fields #11682
    Anh TranAnh Tran
    Keymaster

    Hi Purdue,

    All types should use text or equivalent type for storing the data. So TEXT NOT NULL is 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.

    in reply to: New contexts broken with Gutenberg #11674
    Anh TranAnh Tran
    Keymaster

    @Ale: No, it's not. Gutenberg is JavaScript-editor and it doesn't support many PHP hooks, including contexts.

    in reply to: pre_get_posts to get all posts connected to single object #11659
    Anh TranAnh Tran
    Keymaster

    Hi 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_posts is too late. The plugin uses parse_query hook to setup some parameter for the SQL. So you might want to change your code from pre_get_posts to parse_query.

    in reply to: Data are not saved into the database. #11658
    Anh TranAnh Tran
    Keymaster

    Hi Vadym,

    Can you take a screenshot of the edit screen with all questions and answers?

    in reply to: Cannot add Custom Post Type #11657
    Anh TranAnh Tran
    Keymaster

    Hi Cornwall,

    Can you enable debugging and see if there's any PHP error on the "New Post Type" screen?

    in reply to: Display CPT in page #11656
    Anh TranAnh Tran
    Keymaster

    For 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.

    in reply to: Datetime validation #11655
    Anh TranAnh Tran
    Keymaster

    Hi,

    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 readonly to prevent users entering values in wrong format.

    Anh TranAnh Tran
    Keymaster

    Hi 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.

    in reply to: Display CPT in page #11642
    Anh TranAnh Tran
    Keymaster

    Have you resolved this? Do you need any further help?

    in reply to: Data are not saved into the database. #11639
    Anh TranAnh Tran
    Keymaster

    Hi,

    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.

    in reply to: Cannot add Custom Post Type #11638
    Anh TranAnh Tran
    Keymaster

    Hi 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.

    in reply to: Display CPT in page #11637
    Anh TranAnh Tran
    Keymaster

    I 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 of rwmb_meta function. 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;
        }
      }
    }
    in reply to: Display CPT in page #11629
    Anh TranAnh Tran
    Keymaster

    Hi 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?

    in reply to: MB Settings extension #11625
    Anh TranAnh Tran
    Keymaster

    Hi 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.php file.

    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.

Viewing 15 posts - 1,711 through 1,725 (of 3,708 total)