Skip to content

Instantly share code, notes, and snippets.

@karlazz
Created February 12, 2021 19:44
Show Gist options
  • Save karlazz/3f527021dcaf2d80bf0e910ea53d79f8 to your computer and use it in GitHub Desktop.
Save karlazz/3f527021dcaf2d80bf0e910ea53d79f8 to your computer and use it in GitHub Desktop.
Simple fetch and WP REST API example
fetch("https://domain.com/wp-json/wp/v2/published_rest_accessible_post_type/"+ ID)
.then(response => response.json())
.then(data => document.getElementById("<?php echo $a['dest'];?>").innerHTML= data.content.rendered );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment