Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created August 13, 2012 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjangda/3343560 to your computer and use it in GitHub Desktop.
Save mjangda/3343560 to your computer and use it in GitHub Desktop.
Output a JSON Feed of posts in a zone
<?php
// This will be accessible at /feed/zones-json/
add_feed( 'zones-json', 'x_render_zones_json_feed' );
function x_render_zones_json_feed() {
if ( function_exists( 'z_get_zone_query' ) ) {
$query = z_get_zone_query( 'zone-name' );
header('Content-type: application/json');
echo json_encode( $query->posts ); // you'll obviously want to strip down the data that's output
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment