MITLibraries / headless_wordpress

Run away! This is experimental and not intended to be used for anything.
Apache License 2.0
0 stars 0 forks source link

Notes #1

Open JPrevost opened 7 years ago

JPrevost commented 7 years ago

Wordpress Alt Front End

WpApiClient.configure do |api_client| api_client.endpoint = 'http://libraries.mit.edu/wp-json/wp/v2' end

@api = WpApiClient.get_client

posts = @api.get(‘pages’)

posts.map { |p| puts p.title } Classics – New books SNL Energy: Use restrictions About the new beta search Using the IIIF Mirador viewer Class of 1982 Sequentiary (diva.js) Class of 1982 Sequentiary Experiments graveyard Experiments at the MIT Libraries Welcome, Class of 2021! Code of conduct for events sponsored by the MIT Libraries

posts.first

posts.first.resource._links['up'].first['href']

http://libraries.mit.edu/wp-json/wp/v2/pages/14725

page = @api.get('pages/14725')

page.content

libraries.mit.edu/{slug}/wp-json/wp/v2

Matt Bernhardt [2:47 PM] If you're looking for documentation on the WP API, this is the best place to start: https://developer.wordpress.org/rest-api/

[2:47 PM] You may find yourself back to this eventually: http://v2.wp-api.org/ v2.wp-api.org WP REST API v2 Documentation Documentation for version 2.0 of the WP REST API.

[2:48 PM] That second URL was the home of the API when it was still in plugin form - v2 was the one that eventually was adopted into WP core, I believe without too many changes.

Matt Bernhardt [2:52 PM] http://libraries.mit.edu/wp-json/wp/v2

[2:53 PM] This is the list of news posts that DSpace loads for the front page https://libraries.mit.edu/news/wp-json/wp/v2/posts?tags=162

[2:53 PM] So basically there's a number of sites around the Wordpress network - they each have a JSON API endpoint.