Support General Include custom fields in the standard post object Reply To: Include custom fields in the standard post object

#14064
Anh TranAnh Tran
Keymaster

You mean including custom fields in the response of WP_Query?

If so, then it's not supported. That might lead to a query performance. I think it's better to do something like this:

$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
    $field_value1 = rwmb_meta( 'field_id1' );
    $field_value2 = rwmb_meta( 'field_id2' );
    // Do what you want.
endwhile;

Calling helper function or get_post_meta function inside a loop is a better way, since WP_Query already cache all post meta and they don't create any extra query to the database.