Custom Fields
Support MB Custom Table Function to retrieve all post data from custom table

  • Creator
  • #12550
    Resolved Jefferson

    Exists some function like get_post() that can I use to retrieve all post (relative) data from custom table?

    If not, each field requires a database call?

Viewing 1 replies (of 1 total)
  • Author
  • #12557
    Anh Tran

    Hi Jefferson,

    To get all fields from custom table, you can do a simple query:

    global $wpdb;
    $fields = $wpdb->get_row( "SELECT * FROM your_table WHERE ID={$post_id}" );
    echo $fields->your_field;

    If you use the helper function to get a field value, it will create a very similar query and cache the result. So the next call to get another field’s value, it won’t create any extra DB query.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.


Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.

grid gear info copy caret-up caret-down trash