Upload
todd-mckee
View
82
Download
5
Embed Size (px)
Citation preview
Centralizing News through WordPress REST API
Todd McKee, MEd University of Arkansas for Medical Sciences (UAMS)
Todd McKee, MEd @toddmckee
Senior Web Developer Office of Communications and Marketing
Wordpress at UAMS
• UAMSHealth.com (Hospital & News) • 9000+ posts & pages
• uamsonline.com & uamsonlinedev.com (UAMS multisites) • 150 sites with ~400 users
• uamsonlinetwo.com & uamsdev.com (Institutes) • 7 sites with 1500+ posts
• sites.uams.edu & go.uams.edu (One-offs & Apps) • ~30 sites with ~200 users
• 25+ of single installs (One-offs & special)
Before
College of Medicine
Research
Cancer Institute
Same (-ish) Story. Posted 3 times or more
✂+📋
✂+📋
✂+📋
Content Syndication
• https://premium.wpmudev.org/blog/how-to-manage-the-content-in-your-wordpress-multisite-media-empire/
• https://vip.wordpress.com/plugins/syndication/
Now
College of Medicine
Same Story. Not all sites are available
Cancer Institute
Research
☑
☑
Push
🚫
LEVEL UP: Merging All The Things
https://online.wpcampus.org/schedule/level-up-centralized-news-and-wordpress/
Now
Cancer Institute
College of Medicine
Research
☑
☑
Push
🚫
Soon
Cancer Institute
College of Medicine
ResearchOne Story. Multiple sites
Pull
☁
(Already Started)
• https://wpengine.com/resources/the-ultimate-guide-to-the-wordpress-rest-api/
• https://torquemag.io/2017/05/ways-start-using-wp-rest-api/
• https://jeremyfelt.com/2016/02/17/using-wp-rest-api-washington-state-university/
• https://github.com/washingtonstateuniversity/WSUWP-Content-Syndicate
WHAT IS AN API?
Definition: Application Program Interface (API) is a set of routines, protocols, and tools
for building software applications.
YOU LOST ME AT “DEFINITION”
An API lets you access, or create data. WordPress Terms: The REST API lets you access, or
create, WordPress content.
https://www.slideshare.net/royssivan/wpcampus-online-the-case-for-the-wordpress-rest-api
HOW DO YOU API?
Leveraging the API isn’t that difficult once you get the hang of JSON (JavaScript Object
Notation) Use JavaScript or PHP
RESTful APIRepresentational state transfer (REST) or RESTful web services is an API that uses HTTP requests to GET, PUT, POST and DELETE data (Universal connector for data).
JSON
WP Rest API 101
• WordPress 4.7+
• v2.wp-api.org
• CRUD (Create, Read, Update, Delete)
• /wp-json/wp/v2/
https://www.slideshare.net/AndrewDixon5/an-absolute-beginners-guide-to-the-wordpress-rest-api
Filter
• Add parameters to filter
• Think WP-Query
• GET
• /wp-json/wp/v2/posts?search=awesome
• /wp-json/wp/v2/posts?page=1&per_page=2
• Example
Single Article
• GET /wp-json/wp/v2/posts/{POST-ID}
• Example
What else can we access?
• Pages
• Media
• Custom Post Types
• Taxonomies
• Everything…
Examples
Issues
• Authentication
• Basic, JavaScript, & Oauth
• Cross-Origin Resource Sharing (CORS)
• Extending Support For Custom Content Types
What are we doing?
• News on www.uams.edu
• Image on top of www.uams.edu
• Alert system (WP API v1)
• People / Physician directory (coming soon)
Thank you.
Questions?
Resources
• github.com/UAMS-Web
• github.com/UAMS-Web/UAMSWP-Content-Syndication
• github.com/washingtonstateuniversity
• wpcampus.org