rwmb_get_value( ) accepted argument request

Support General rwmb_get_value( ) accepted argument request

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9314
    foundbutlostfoundbutlost
    Participant

    can you make this function work like get_term_meta() wordpress function does?

    rwmb_get_value( $field_id, $args, $post_id );

    i mean if i dont specify $field_id or leave it blank, then all meta related to the $post_id will be returned as:

    Array ( 
    [field_id1] => Array ( 
                         [0] => value1 
                         ), 
    [field_id2] => Array ( 
                         [0] => value2 
                        )
    )

    it will be really helpful on my custom table. thanks.

    #9321
    Anh TranAnh Tran
    Keymaster

    Hi, why don't you just use get_post_meta() instead? Using the helper function will run through all custom fields and prepare the values for all of fields, which is an extensive job. It's not a good choice for performance.

    #9323
    foundbutlostfoundbutlost
    Participant

    How do i achieve that if i'm using a custom table to store the meta?

    #9325
    Anh TranAnh Tran
    Keymaster

    Well, you can do a simple query like this:

    global $wpdb;
    $values = $wpdb->get_result( $wpdb->prepare( "SELECT * FROM your_table WHERE ID=%d", $post_id ), ARRAY_A );
    #9349
    foundbutlostfoundbutlost
    Participant

    Yep, actually i'm currently using that right now. Thank you and closed!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘rwmb_get_value( ) accepted argument request’ is closed to new replies.