Skip to content

Instantly share code, notes, and snippets.

@plpepin
Created February 22, 2019 17:32
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 plpepin/de6fe478be80c11de4c33a7aee3f1ff2 to your computer and use it in GitHub Desktop.
Save plpepin/de6fe478be80c11de4c33a7aee3f1ff2 to your computer and use it in GitHub Desktop.
// Where is the code going?
cssSel_Content = .somedialog .dialog__content;
$dlgContent = jQuery( cssSel_Content );
// Grab the content and paste it inside its destination
wordpress_site_url = 'http://www.somesite.com';
wordpress_page_slug = 'some-page-slug';
jQuery.get( wordpress_site_url + '/wp-json/wp/v2/pages', {
slug: wordpress_page_slug,
per_page: 1
}, function( pages ) {
gridContent = pages[0].grid; // returned variable is an array ;)
pageContentRows = JSON.parse( gridContent ).cont; // content returns all rows as an array
jQuery.each(pageContentRows, function(index, content) {
$dlgContent.append( content.cont );
});
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment