I have an ionic app getting json data and I added Advanced Custom Fields so I can 'embed' a video (youtube, vimeo, etc.) in a post. The problem is it's only getting the html code (). How can I have it to where it's actually displaying the video?
Asked
Active
Viewed 245 times
1 Answers
1
If you need to get a meta field of your post (ex. id = 123) with wp-api you can do this:
jQuery.ajax({
url: '/wp-json/posts/123/meta',
type: 'GET',
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader('X-WP-Nonce', WP_API_Settings.nonce);
}
}).done( function( data ) {
console.log( data );
});
If WP_API_Settings is not defined you need to load wp-api.js in the enqueue action:
wp_register_script( 'myscript', plugin_dir_url( __FILE__ ) . 'myscript.js', array( 'wp-api' ) );
wp_enqueue_script( 'myscript' );

Mat
- 2,156
- 2
- 16
- 29
-
I haven't tried v2 yet, it is in beta. I'm using the current stable (1.2.4) – Mat Dec 04 '15 at 08:09