WordPress JSON output
If you are using PHP 5.2+ you’re best bet is to just make a PHP array or object and use json_encode(). UPDATED: $cats = get_categories(); $output = array(‘categories’ => array()); foreach ($cats as $cat) { $cat_output = array( ‘cat_id’ => $cat->term_id, ‘cat_name’ => $cat->name, ‘posts’ => array(), ); // should be able to use -1 … Read more