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

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 8 months, 2 weeks ago.

  • Creator
    Topic
  • #12550
    Resolved
    Jefferson
    Participant

    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
    Replies
  • #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.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.