Pushing posts in WordPress and reading inside Laravel

I try to read WordPress posts using WordPress and push them inside a Laravel application.

How to push posts from WordPress and read them in Laravel?

An example code to use REST API:

let inputConfig = input.config();

const WordPressAPI = (function () {
  const baseUrl = inputConfig.wordpressBaseUrl;
  const wordpressAPIKey = inputConfig.wordpressAPIKey;

  const fetchPosts
  const fetchPostById

Source like Accessing All WordPress Posts using REST API V2: https://wp-umbrella.com/blog/wordpress-rest-api/

Hello @toplisek

I assume you know how to make API requests to the API based on that article. So at this point you should be able to get a list of posts out of WordPress.

You can fetch this data from within your controllers in Laravel. Once you have the collection setup, it is just a matter of passing that collection of results to the view. In the view you can then loop through them using blade syntax.

You can see this process in the article I have linked below. There is some code there you can see where the author fetches dog breed information from an API, then passes it along to the view for rendering inside a Laravel blade template.

I hope this is what you were asking about. :slight_smile:

Thank you for the message!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.