I’m working on a project where I need to show recent blog posts from a WordPress site on a different website. The catch is, I don’t want to install WordPress on my server.
I’ve been looking at the WordPress API, but all the guides I’ve found say you need to have WordPress installed to use it. Is this really the only way?
I’m hoping there’s a method to fetch recent posts without setting up WordPress on my end. All I want is to display a list of the latest articles with links to the original blog.
Has anyone done something like this before? Any tips or alternatives would be super helpful. Thanks!
hey ethan, u can totally do this without installing wp! check out the wp rest api since most sites have it public. just make a GET req to yoursite.com/wp-json/wp/v2/posts and fetch the lates posts. hope it helps!
I’ve actually implemented something similar for a client recently. You’re on the right track with the WordPress REST API - it’s a powerful tool for accessing WP content externally.
To fetch recent posts, you can indeed use the endpoint Liam23 mentioned, but you might want to add some parameters for better control. For instance, yoursite.com/wp-json/wp/v2/posts?per_page=5&orderby=date&order=desc will give you the 5 most recent posts.
One thing to keep in mind is that some WordPress sites might have the REST API disabled or restricted. In such cases, you could explore alternative methods like RSS feeds (if enabled) or even web scraping as a last resort.
For displaying the posts, you’ll need to parse the JSON response and render it on your site. This can be done with JavaScript on the client-side or server-side depending on your setup.
Remember to handle errors gracefully and implement caching to avoid hammering the WordPress site with frequent requests. Good luck with your project!