I have a WordPress blog and a PHP website. I intend to feed the last 6 posts from that WordPress blog to this PHP website. Taking the title, url and thumbnail, and all this from two specific post category. Can anyone help me the best and simple way to do that? I’m a front end developer and I’m not so good in PHP =/
Thanks in advance!
You can try this method
Install WP API
Get the JSON URL of what you want to load, refer to docs
e.g.
http://yourdomain.com/wp-json/wp/v2/pages?filter[posts_per_page]=6&filter[orderby]=date
$posts = json_decode(file_get_contents('http://yourdomain.com/wp-json/wp/v2/pages?filter[posts_per_page]=6&filter[orderby]=date'));
foreach ( $posts as $post ) {
echo '<a href="'.$post->link.'">'.$post->title->rendered.'</a>';
}
There is plugins that can help you move the data from and to your WP site.. Check out this link about WP plugins and RSS feeds
http://mashable.com/2008/09/08/rss-plugins-for-wordpress/#haJPCZ7VPaqG
An Easy Way to Display an RSS Feed with PHP
The following code will first create a new DOMDocument() into which we will load the WordPress.org RSS feed.
Then we will single out certain elements and place them into an array. For this example, I will just fetch the title, description, link and published on date.
Finally, we set it to display 5 posts on screen with the titles linking directly to the original post.
Not too complicated. All you need to change is the feed you want to load (line #3) and the number of posts to display (line #14). Of course, you could always play around with the output to get it styled exactly how you want. That is totally up to you.