07-27-2023, 10:16 AM
I'm doing an AJAX request using admin-ajax.php whereby I filter posts based on which check-box is checked. It's working great, although I'm struggling to find a way to return the meta details of each post.
I'm just using query_posts to get my data as below:
function ajax_get_latest_posts($tax){
$args= array(
'post_type'=>'course',
'tax_query' => array(
array(
'taxonomy' => 'subject',
'field' => 'slug',
'terms' => $tax
)
)
);
$posts=query_posts( $args);
return $posts;
}
How would I modify this to also return meta data? I know I can filter the posts by meta data using meta_query, but I just want to display the data in my posts.
I'm just using query_posts to get my data as below:
function ajax_get_latest_posts($tax){
$args= array(
'post_type'=>'course',
'tax_query' => array(
array(
'taxonomy' => 'subject',
'field' => 'slug',
'terms' => $tax
)
)
);
$posts=query_posts( $args);
return $posts;
}
How would I modify this to also return meta data? I know I can filter the posts by meta data using meta_query, but I just want to display the data in my posts.