WP_Query To call data from diffrent tables

I need to retrieve data from multiple tables , wp_postmeta to get posts with a specific type ( question ) , wp_user for author informations and also wp_comments .

I need those information to use them in my rest api

I have already created a new route

add_action(‘rest_api_init’, function () {

register_rest_route( ‘myroute/v1’, ‘mydata/’,array(
‘methods’ => ‘GET’,
‘callback’ => ‘get_data’
));
});

function get_data($request) {

$args = array(
‘post_type’ => ‘question’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 8,
);

How can i join my request and get data from multiple tables

I need author’s name and number of comments for every post

Read more here:: WP_Query To call data from diffrent tables

Leave a Reply

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