Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'json_init' );
- function json_init() {
- add_feed( 'json', 'viper_json' );
- add_rewrite_tag( '%json_id%', '([0-9]+)' );
- add_rewrite_rule( '^feed/json/id/([0-9]+)/?', 'index.php?feed=json&json_id=$matches[1]', 'top' );
- }
- function viper_json() {
- if ( ! get_query_var( 'json_id' ) )
- exit( 'missing id' );
- $id = get_query_var( 'json_id' );
- $post = get_post( $id );
- echo json_encode( $post );
- exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement