get posts using javascript
-
Hello, I want to have list of recent posts on my website. How can I query it using javascript? Is it exposed thru JSON?
The blog I need help with is: (visible only to logged in users)
-
Hi Vitali – You can simply use the Recent Posts widget: Recent Posts Widget
Here on WordPress.com, it’s not possible to use JavaScript or edit the HTML of your theme files. If you want to be able to do that, you might be interested in a self-hosted WordPress installation. You can read more about the differences here: http://en.support.wordpress.com/com-vs-org/
-
Hello, thanks for your reply. I already know and use widget for my blog. That’s not quite what I meant to ask. I want to include a list of the latest posts from my blog on my personal website.
-
Hi Vitali – Assuming your personal website is self-hosted WordPress, that’s a question for the WordPress.org forums here:
http://wordpress.org/support/They should be able to advise you how best to accomplish this. I think there are also a couple of plugins that display a feed of a given site on your website that might work for you. :)
-
Again that’s not what I meant to ask. I have a blog hosted at wordpress.com. I have a personal website hosted at godaddy. I don’t host wordpress on my website. I want to have links on my website to a few recent posts on my blog. Right now I achieve this by using google API to pull RSS feed from wordpress and then translate it using xslt into html. Unfortunately recently google blocked there API for Internet Explorer. So, now I’m looking for native wordpress API. Something similar to flickr feeds API (http://www.flickr.com/services/feeds/docs/activity/) that I use to get entries from my flickr feed and incorporate them into my website. All done in javascript on my website.
-
Something like what is described at http://vip.wordpress.com/plugins/json-feed/ except it does not work for me: http://blog.vitphoto.com/feed/json
-
Hi Vitali – Ah, ok, I understand now.
The plugin you link to is for use only on VIP WordPress.com sites, but we have developer documentation on the WordPress.com Rest API here that might be of help to you:
http://developer.wordpress.com/docs/api/ -
Thanks! That’s what I have been looking for. And I’ve already tested and it gets me what I needed.
-
Hi Vitali – Perfect! I’m glad it’s working for you. Let us know if you need anything else.
-
Something strange is going on. I’ve added javascript to use this API and it works perfectly when I open html on my desktop as a local file. But once I upload and open my website the API returns nothing.
Here is a javascript snippet of my code:
var feeds = {
init: function () {
setTimeout(function () { feeds.blog.query(); }, 500);
},blog: {
query: function () {
// API docs: http://developer.wordpress.com/docs/api/
$.getJSON(‘https://public-api.wordpress.com/rest/v1/sites/blog.vitphoto.com/posts/?number=5&pretty=1’, function (data) { feeds.blog.process(data); });
},process: function (data) {
var html = ‘- ‘;
- <p>’ + post.title + ‘</p><div class=”date”>’ + post.date + ‘</div>
// Loop through the results with the following function.
$.each(data.posts, function (i, post) {
// Build html.
html += ‘‘;
});html += ‘
‘;
$(‘#blog’).html(html);
}
},
}; -
Hi Vitali – Can you please submit this as a question to our developers here:
http://developer.wordpress.com/contact/Thanks very much!
- The topic ‘get posts using javascript’ is closed to new replies.