adding custom fields and meta to json rest api

im using the json rest api for my wordpress and i have a custom post type.
my custom post type have a few custom fields and meta’s but i cant get them from json api is there anyone to solve the problem?

this is my json url:
https://mtdgroup.co/wp-json/wp/v2/avada_portfolio

and the problem is my custom post type named avada_portfolio but without meta_keys and custom fields.

i have a code but its not working:

function my_allow_meta_query( $valid_vars ) {

$valid_vars = array_merge( $valid_vars, array( ‘meta_key’, ‘meta_value’ ) );
return $valid_vars;
}
add_filter( ‘rest_query_vars’, ‘my_allow_meta_query’ );

Read more here:: adding custom fields and meta to json rest api

Leave a Reply

Your email address will not be published. Required fields are marked *