Customize JSON output
This code will do the job: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); $posts = array(); $categories = array(); $json = array(); while( $query->have_posts() ) : $query->the_post(); $post_categories = get_the_category(); $post_category = current($post_categories); $categories[] = array( ‘name’ => $post_category->name ); $posts[] = array( … Read more