Skip to content

Instantly share code, notes, and snippets.

@scottbaggett
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save scottbaggett/10700382 to your computer and use it in GitHub Desktop.

Select an option

Save scottbaggett/10700382 to your computer and use it in GitHub Desktop.
Post save callback to cache JSON api
function post_saved_json_callback($post_id)
{
$url = "http://localhost/api/get_posts/?post_type=page,artist,release,episode,post&posts_per_page=10000";
$content = file_get_contents($url);
$output = TEMPLATEPATH . '/brunch-app/public/data/posts.json';
file_put_contents($output, $content);
}
// save post updates the json file
add_action( 'save_post', 'post_saved_json_callback' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment