SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
WordPress as a Headless CMS
Using Wordpress’ REST API to Decouple Your CMS.
Adam Rasheed
Front-end Developer
Specialize in WordPress & Shopify.
Currently Learning React
What is a Headless CMS?
• AKA Decoupled CMS
• Allows your to break through the limits of the CMS by separating the
presentation model and the data layer.
• “Decouples” the front-end from the CMS/Backend
What is a Headless CMS?
Server/Database Wordpress CMS
Website
Mobile App
JSON
Data
Why Headless?
• Future-proof sites – lets you implement a
redesign without redoing your CMS structure.
• Full Control of Front-end – Gives your front-
end full control the user experience, as
opposed to coding things the “wordpress way”
• Interactive experiences – let’s you use front-
end frameworks like React or Vue to make
web apps.
• Let’s you import data into another CMS (e.g.
use a Wordpress Blog on a Shopify site).
Getting Started
Walking Through My Personal Site
• Scotchbox & WP- Distillery <- Recommended
• Local by FlyWheel <- If Scotchbox fails
Local Development - Wordpress
Local Development - React
• Create React App
• Gatsby.js <- React Framework
Setting Up Wordpress
• No Need for Themes (use a blank one if
you want)
• If you use Advanced Custom Fields, use the
acf-to-rest-api plugin
• If you use any security plugins, make sure
you allow REST API access (e.g. iThemes)
• That’s it for Wordpress!
REST API
• Documentation:
• https: //developer.wordpress.org/rest-api/
• Endpoint:
• https: //domain.com/wp-json/
• Example - Posts
• http: //demo.wp-api.org/wp-json/wp/v2/posts
REST API - Posts
http://adam-rasheed-headless.local/wp-json/wp/v2/posts
REST API - Posts
http://adam-rasheed-headless.local/wp-json/wp/v2/posts
https://jslint.com
Pulling in Data to React
• Use Fetch, Async Await, or a library like Axios to pull in API data into your
web app.
• If using React, pull in data if component mounted. Saves a lot of data.
Quick Demo 💻
Pushing The Site Live
• Wordpress and your Front-end Site can live
on two separate hosts. (I’m planning on
using DigitalOcean for Wordpress, Netflify
for React).
• Quick-and-easy way to migrate live: 1) push
the WP site live, then change the endpoints
in your React to point to the live WP site,
then push the React Site live.
Next Steps
• Take an existing WordPress site you already have, and look at it’s REST
API
• Use the REST API to build out a new site in React/Vue/Angular, or even
create a static site and pull in the API with vanilla javascript!
• Keep in mind, you don’t have to go fully headless!
Nearly Headless CMS
• You can add interactive elements to your
WordPress site by implementing the REST
API
Some Ideas:
• Create a “Load More” button for your blog
post roll that pulls in the next 8 blog posts
without reloading the page
• Creating a twitter-like “like count” that
shows the “likes” each post has in real-
time
Resources
• REST API Docs - https://developer.wordpress.org/rest-api/
• ACF to REST API - https://github.com/airesvsg/acf-to-rest-api
• React - https://reactjs.org/
• GatsbyJS - https://www.gatsbyjs.org/
• Fetch API docs - https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
• Async Await Docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
Statements/async_function
• WP GraphQl - https://github.com/wp-graphql/wp-graphql
Thanks! "

Contenu connexe

Tendances

Web Cookies
Web CookiesWeb Cookies
Web Cookies
apwebco
 
개발을잘하고싶어요-네이버랩스 송기선님
개발을잘하고싶어요-네이버랩스 송기선님개발을잘하고싶어요-네이버랩스 송기선님
개발을잘하고싶어요-네이버랩스 송기선님
NAVER D2
 

Tendances (20)

Content Management System - CMS
 Content Management System - CMS Content Management System - CMS
Content Management System - CMS
 
Intro to web scraping with Python
Intro to web scraping with PythonIntro to web scraping with Python
Intro to web scraping with Python
 
Basic Wordpress PPT
Basic Wordpress PPT Basic Wordpress PPT
Basic Wordpress PPT
 
Web Cookies
Web CookiesWeb Cookies
Web Cookies
 
Building Responsive Applications Using XPages
Building Responsive Applications Using XPagesBuilding Responsive Applications Using XPages
Building Responsive Applications Using XPages
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Web development phases
Web development phasesWeb development phases
Web development phases
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
 
Content management system
Content management systemContent management system
Content management system
 
React js Demo Explanation
React js Demo ExplanationReact js Demo Explanation
React js Demo Explanation
 
Web development ppt
Web development pptWeb development ppt
Web development ppt
 
무정지&무점검 서버 개발과 운영 사례
무정지&무점검 서버 개발과 운영 사례무정지&무점검 서버 개발과 운영 사례
무정지&무점검 서버 개발과 운영 사례
 
개발을잘하고싶어요-네이버랩스 송기선님
개발을잘하고싶어요-네이버랩스 송기선님개발을잘하고싶어요-네이버랩스 송기선님
개발을잘하고싶어요-네이버랩스 송기선님
 
프론트엔드 개발자를 위한 Layer Model
프론트엔드 개발자를 위한 Layer Model프론트엔드 개발자를 위한 Layer Model
프론트엔드 개발자를 위한 Layer Model
 
Web development presentation
Web development presentationWeb development presentation
Web development presentation
 
Intro to Wordpress
Intro to WordpressIntro to Wordpress
Intro to Wordpress
 
Getting started with Web Scraping in Python
Getting started with Web Scraping in PythonGetting started with Web Scraping in Python
Getting started with Web Scraping in Python
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development Presentation
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbie
 
Introduction to MERN Stack
Introduction to MERN StackIntroduction to MERN Stack
Introduction to MERN Stack
 

Similaire à Using WordPress as a Headless CMS

Microsoft WebMatrix Platform Overview
Microsoft WebMatrix Platform OverviewMicrosoft WebMatrix Platform Overview
Microsoft WebMatrix Platform Overview
Spiffy
 

Similaire à Using WordPress as a Headless CMS (20)

Building a Headless Shop
Building a Headless ShopBuilding a Headless Shop
Building a Headless Shop
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Build Web Applications
Build Web ApplicationsBuild Web Applications
Build Web Applications
 
WebMatrix
WebMatrixWebMatrix
WebMatrix
 
Introduction to web pi and web matrix
Introduction to web pi and web matrixIntroduction to web pi and web matrix
Introduction to web pi and web matrix
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
 
Agile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic BeanstalkAgile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic Beanstalk
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHP
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
 
Faster WordPress Workflows
Faster WordPress WorkflowsFaster WordPress Workflows
Faster WordPress Workflows
 
React + Flux = Joy
React + Flux = JoyReact + Flux = Joy
React + Flux = Joy
 
Agile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic BeanstalkAgile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic Beanstalk
 
Chapter 26
Chapter 26Chapter 26
Chapter 26
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Today
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPress
 
React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016
 
Single Page Apps
Single Page AppsSingle Page Apps
Single Page Apps
 
Domain and hostion
Domain and hostionDomain and hostion
Domain and hostion
 
Microsoft WebMatrix Platform Overview
Microsoft WebMatrix Platform OverviewMicrosoft WebMatrix Platform Overview
Microsoft WebMatrix Platform Overview
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Using WordPress as a Headless CMS

  • 1. WordPress as a Headless CMS Using Wordpress’ REST API to Decouple Your CMS.
  • 2. Adam Rasheed Front-end Developer Specialize in WordPress & Shopify. Currently Learning React
  • 3. What is a Headless CMS? • AKA Decoupled CMS • Allows your to break through the limits of the CMS by separating the presentation model and the data layer. • “Decouples” the front-end from the CMS/Backend
  • 4. What is a Headless CMS? Server/Database Wordpress CMS Website Mobile App JSON Data
  • 5. Why Headless? • Future-proof sites – lets you implement a redesign without redoing your CMS structure. • Full Control of Front-end – Gives your front- end full control the user experience, as opposed to coding things the “wordpress way” • Interactive experiences – let’s you use front- end frameworks like React or Vue to make web apps. • Let’s you import data into another CMS (e.g. use a Wordpress Blog on a Shopify site).
  • 7. • Scotchbox & WP- Distillery <- Recommended • Local by FlyWheel <- If Scotchbox fails Local Development - Wordpress
  • 8. Local Development - React • Create React App • Gatsby.js <- React Framework
  • 9. Setting Up Wordpress • No Need for Themes (use a blank one if you want) • If you use Advanced Custom Fields, use the acf-to-rest-api plugin • If you use any security plugins, make sure you allow REST API access (e.g. iThemes) • That’s it for Wordpress!
  • 10. REST API • Documentation: • https: //developer.wordpress.org/rest-api/ • Endpoint: • https: //domain.com/wp-json/ • Example - Posts • http: //demo.wp-api.org/wp-json/wp/v2/posts
  • 11. REST API - Posts http://adam-rasheed-headless.local/wp-json/wp/v2/posts
  • 12. REST API - Posts http://adam-rasheed-headless.local/wp-json/wp/v2/posts https://jslint.com
  • 13. Pulling in Data to React • Use Fetch, Async Await, or a library like Axios to pull in API data into your web app. • If using React, pull in data if component mounted. Saves a lot of data.
  • 15. Pushing The Site Live • Wordpress and your Front-end Site can live on two separate hosts. (I’m planning on using DigitalOcean for Wordpress, Netflify for React). • Quick-and-easy way to migrate live: 1) push the WP site live, then change the endpoints in your React to point to the live WP site, then push the React Site live.
  • 16. Next Steps • Take an existing WordPress site you already have, and look at it’s REST API • Use the REST API to build out a new site in React/Vue/Angular, or even create a static site and pull in the API with vanilla javascript! • Keep in mind, you don’t have to go fully headless!
  • 17. Nearly Headless CMS • You can add interactive elements to your WordPress site by implementing the REST API Some Ideas: • Create a “Load More” button for your blog post roll that pulls in the next 8 blog posts without reloading the page • Creating a twitter-like “like count” that shows the “likes” each post has in real- time
  • 18. Resources • REST API Docs - https://developer.wordpress.org/rest-api/ • ACF to REST API - https://github.com/airesvsg/acf-to-rest-api • React - https://reactjs.org/ • GatsbyJS - https://www.gatsbyjs.org/ • Fetch API docs - https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API • Async Await Docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ Statements/async_function • WP GraphQl - https://github.com/wp-graphql/wp-graphql