Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1,066 through 1,080 (of 3,707 total)
  • Author
    Posts
  • in reply to: Choose File in custom table #14811
    Anh TranAnh Tran
    Keymaster

    Hi Dave, sorry for the delay. I couldn't find anything wrong with the code. Can you send me a temporary admin account to take a look into that closer?

    in reply to: Prefix in missing in the builder? #14802
    Anh TranAnh Tran
    Keymaster

    Prefix is just an option and sometimes, it confuses people. So in the MB Builder, we don't include it. You can add the prefix manually in the ID fields if you want.

    in reply to: Open Street Map: View all post of one cpt #14783
    Anh TranAnh Tran
    Keymaster

    Sorry for the delay, here you are.

    in reply to: MB Relationships display only post name #14778
    Anh TranAnh Tran
    Keymaster

    Hmm, looks like the disabled elements won't be submitted when submitting the form.

    I think both issues (disable selection and limit the query) can be done like this:

    • Make an extra query to get the current selected options (do it by making a SQL query directly to the database). With this, you get the IDs of the connected posts.
    • Set the post__in for query_args in the relationship meta box. So the query only get the selected items.
    in reply to: Duplicate posts returned from relationship query #14764
    Anh TranAnh Tran
    Keymaster

    Hi, it's a bug when running the SQL. I've just fixed it here. Can you try it?

    in reply to: Choose File in custom table #14761
    Anh TranAnh Tran
    Keymaster

    If the field is updating, that means it still saves values in the post meta. Can you verify that?

    And did you put all the fields in one meta box?

    in reply to: MB Relationships display only post name #14759
    Anh TranAnh Tran
    Keymaster

    You can set query_args parameter for from and to to limit the query. If you know the IDs of selected items, you can do this:

    MB_Relationships_API::register( [
        'id'   => 'posts_to_pages',
        'from' => [
            'post_types' => 'post',
            'query_args' => [ 'post__in' => [1,2,3], 'posts_per_page' => 10 ],
        ],
        'to'   => 'page',
    ] );
    in reply to: Choose File in custom table #14758
    Anh TranAnh Tran
    Keymaster

    I don't see anything wrong here. Do you see other fields saved in the database?

    in reply to: MB Custom Table and wp_insert_post #14756
    Anh TranAnh Tran
    Keymaster

    Hi Will,

    For WP_Query, the plugin doesn't integrate with it. You need to perform an extra query to get the posts you want, then use the returned ID to create your own WP_Query.

    global $wpdb;
    $ids = $wpdb->get_col( "SELECT ID FROM your_table WHERE field1='value1' OR field2='value2'" );
    
    $query = new WP_Query( [
        'post_type' => 'post',
        'post__in'  => $id,
    ] );
    in reply to: Choose File in custom table #14754
    Anh TranAnh Tran
    Keymaster

    Probably you need to increase the length for the field. The value of image field is an array of IDs, which will be serialized before saving in the database.

    For example, if you have 2 images [12, 34], then the value will be a:2:{i:0;i:12;i:1;i:34;}. It's longer than what we think 🙂

    in reply to: Limitations of select_tree (field_type) #14750
    Anh TranAnh Tran
    Keymaster

    Hi ComSi,

    Have you ever drag and drop the meta boxes? If you have, then WP will save the position/location of them and makes the "context" param not working. The data is saved in the user meta meta-box-order_{screen id}:

    https://imgur.elightup.com/A7bkxT9.png

    Deleting this user meta from the database will make the context work again.

    Please try that. It's the only reason I think affects the wrong location.

    in reply to: Choose File in custom table #14749
    Anh TranAnh Tran
    Keymaster

    Hi Dave,

    Storing ID seems better in my opinion. You can get full file info later with small piece of code. Storing file path doesn't have any benefit since it's the raw path on the server, which is unusable.

    in reply to: Set Selected by default in Radio box #14746
    Anh TranAnh Tran
    Keymaster

    Probably, you're on an old post or your meta box has already been saved. See this for more details:

    https://docs.metabox.io/field-settings/#default-value

    in reply to: Duplicate group fields feature #14745
    Anh TranAnh Tran
    Keymaster

    I see. That's an opinion. Some people want to start over again to select different options for the new clone. And the existing values might take them a lot of time deleting unnecessary values, especially the group has cloneable sub-groups.

    Each option will have pros and cons. It's a choice that we made from the beginning, and changing it won't be a reasonable solution for now.

    in reply to: Problem with rwmb_get_value #14744
    Anh TranAnh Tran
    Keymaster

    Hi Camilo,

    Actually, you are setting the field in opposite. The correct pattern should be:

    'value1' => 'Label 1',
    'value2' => 'Label 2'

    (It's the 'value' => 'Label', not 'key' => 'value').

    And the helper function returns the values, not labels.

    You can get the labels, you can do this:

    $field = rwmb_get_field_settings( 'field_id' );
    $options = $field['options'];
    
    // Get all labels.
    $values = rwmb_meta( 'field_id' );
    $labels = array_map( function( $value ) use ( $options ) {
        return $options[$value];
    }, $values );
    
    // Output labels.
    foreach ( $labels as $label ) {
        echo $label;
    }
Viewing 15 posts - 1,066 through 1,080 (of 3,707 total)