I want to make json array of custom post type using wp_query
.This function will echo
post datas like the title and etc.. Is there any way to using wp_query
to making an array like this :
Note: I just put a sample for you to understanding my point.
$query = new WP_Query($args);
$dataArray = [];
while ( $query->have_posts() ) : $query->the_post();
$dataArray = array(
'title' => the_title()
);
endwhile;
$JSON = json_encode($dataArray);
echo $JSON;