Using Wp_query to make json array
-
I want to make json array of custom post type using
wp_query
.This function willecho
post datas like the title and etc.. Is there any way to usingwp_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;
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Using Wp_query to make json array’ is closed to new replies.