Home › Forums › JavaScript › wordpress rss feed help
- This topic is empty.
-
AuthorPosts
-
October 13, 2012 at 9:11 am #40270
rabbid
Memberbasically i am trying to run a feed on another website not hosted by wordpress. i have the following code that works ok, but im looking to make some tweaks or find another code that does what im looking for.
what i want from feed is the last 3 posts.
from each post i want the Title, main message & author.
i do not want the date info, any images, filed under categories, and ‘add a comment’ box.
you can preview [here…](http://www.rabbiddesign.com/icontest/index.html “footertest”)
Thanks for any input!—code—
- Loading…
// ================================================
// Your info here
// ================================================
var feedURL = 'http://rabbidblog.wordpress.com/feed';
var numEntries = 3;
var blogURL = 'http://rabbidblog.wordpress.com/';
var blogLink = 'View full blog ยป';
// ================================================google.load("feeds", "1");
function formatDate(d, f) {
var d = new Date(d);
var months = ;
var days = ;
return f.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a/p)/gi,
function($1) {
switch ($1.toLowerCase()) {
case 'yyyy': return d.getFullYear();
case 'mmmm': return months[d.getMonth()];
case 'mmm': return months[d.getMonth()].substr(0, 3);
case 'mm': return (d.getMonth() + 1);
case 'dddd': return days[d.getDay()];
case 'ddd': return days[d.getDay()].substr(0, 3);
case 'dd': return d.getDate();
case 'hh': return ((h = d.getHours() % 12) ? h : 12);
case 'nn': return d.getMinutes();
case 'ss': return d.getSeconds();
case 'a/p': return d.getHours() < 12 ? 'a' : 'p';
}
}
);
}function initialize() {
var feed = new google.feeds.Feed(feedURL);
feed.setNumEntries(numEntries);
feed.load(function(result) {if(result.error) return;
var list = document.getElementById('entries');
list.removeChild(list.firstChild);for(var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries;
var link = document.createElement('a');
link.setAttribute('href', entry.link);
link.appendChild(document.createTextNode(entry.title));
var title = document.createElement('h2');
title.appendChild(link);
var date = document.createElement('p');
date.setAttribute('class', 'blog_date');
date.appendChild(document.createTextNode(formatDate(entry.publishedDate, 'mmmm dd, yyyy')));
var content = document.createElement('div');
content.innerHTML = entry.content;
var li = document.createElement('li');
li.appendChild(title);
li.appendChild(date);
li.appendChild(content);
list.appendChild(li);
}});
}google.setOnLoadCallback(initialize);
—end— -
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.