0

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?

Mark B
  • 167
  • 3
  • 13

1 Answers1

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