Accessing WordPress Post through Laravel
In the previous tutorial we have learn as how to Install WordPress inside a Laravel application in a subdirectory and same domain and access it using
example.com/blog/. In this tutorial we will be learning as how to access WordPress
page, or any
custom post type data through Laravel.
There are 2 ways to do this
- Through WordPress REST API
- Directly access WordPress database through Laravel Modal
Directly access WordPress database through Laravel Modal
We need to create Modal
BlogPostmeta to access data from
wp_postmeta table respectively.
Now as we have set the database connection and model last thing that we need is to retrieve post. In controller we have to use our Post model to get
$posts will hold all your active published post and under
postmetas key it will be holding all the meta’s that are related to that specific post.
In next tutorial we will be digging deep into WP Comments and WP Author.