Skip to content

Instantly share code, notes, and snippets.

@AaronRutley
Created November 15, 2016 22:56
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 AaronRutley/7368e62369865deb3322ad788ba5dab0 to your computer and use it in GitHub Desktop.
Save AaronRutley/7368e62369865deb3322ad788ba5dab0 to your computer and use it in GitHub Desktop.
<?php
function ar_register_project_meta() {
register_api_field(
'project',
'meta',
array(
'get_callback' => 'ar_register_project_meta_get',
)
);
}
function ar_register_project_meta_get( $object, $field_name, $request ) {
return array(
'location' => get_post_meta( $object[ 'id' ], 'project_location', true ),
'thumbnail_image' => get_field('thubmnail_image', $object[ 'id'] )
);
}
add_action( 'rest_api_init', 'ar_register_project_meta' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment