testing

include(“../wp-config.php”); header(‘Content-type: application/json;’); /* Use this variable for preparing the result to be send back as json response */ $op = array(); $cat_args=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ); $categories=get_categories($cat_args); foreach($categories as $category) { $args=array( ‘showposts’ => -1, ‘category__in’ => array($category->term_id), ‘caller_get_posts’=>1 ); $posts=get_posts($args); if ($posts) { foreach($posts as $post) { /* prepare individual item to be pushed into the result array */ $jsonpost = array(); $jsonpost[‘post_title’]=get_the_title(); $jsonpost[‘content’]=apply_filters(‘the_content’, $post->post_content); $jsonpost[‘image_url’]=wp_get_attachment_url( get_post_thumbnail_id($id, ‘thumbnail’) ); $jsonpost[‘date’]=get_the_date(‘d F Y’); /* push the item on to the result array */ $op[] = array(‘request’ => ‘all_posts’, ‘data’=> $jsonpost) } } } /* array should be complete at this point encode it as json string and send back */ echo json_encode($op);