Custom Fields
Re-Envisioned
Support MB Custom Table Function to retrieve all post data from custom table Reply To: Function to retrieve all post data from custom table

#12557

Anh Tran
Keymaster

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.