I have a Google Feed script working quite well, except that when new
blog items are created or updated, my feed using the script does not
update.  Randomly I can get the feeds to update (not sure how) but not
consistently.

The feed is pulling from a Wordpress Blog.

I am guessing that the feed variable needs to be reset because it is
storing the XML in the browser from my Wordpress blog?

Any suggestions?  Do I need a function that resets var feed?  If so,
how do I do that?

My script has two feeds, for two different parts of the page (querying
by category).  Here is my script:

<script type="text/javascript">
    var feed = 0;
                google.load("feeds", "1");
    google.setOnLoadCallback(BlogFeed);
                google.setOnLoadCallback(EventFeed);
                String.prototype.truncate = function(to_length){
                                if(to_length >= this.length)return
this;
                                return this.substring(0,
to_length-3)+'...';
                                }
    function BlogFeed() {
      var feed = new google.feeds.Feed("http://edgeworksclimbing.com/
blog/feed/");
                  feed.setNumEntries(10);
      feed.load(function(result) {
        if (!result.error) {
                                  var container =
document.getElementById("blog-headline");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var date = new Date(entry.publishedDate);
                                                date =
date.toDateString().substr(4);
                                                var blogcategory =
entry.categories;
                                                if(blogcategory !=
"Events") {
                                                                var li
= document.createElement("li");
 
li.className = "rss-item";
 
li.innerHTML = '<a class="rss-item" href="' + entry.link + '"
target="_self">' + entry.title + '</a><br>';
 
li.innerHTML += '<a class="rss-date" href="' + entry.link + '"
target="_self">' + date + '<cite class="rss-author"> by ' +
entry.author + '</cite></a> ' + entry.categories + '<br>';
 
li.innerHTML += '<a class="rss-snippet" href="' + entry.link + '"
target="_self">' + entry.contentSnippet.truncate(50) + '</a>';
 
container.appendChild(li);
                                                }
          }
        } else {
                                                var container =
document.getElementById("blog-headline");
                                    container.innerHTML = '<li><a
href="http://www.edgeworksclimbing.com/blog";>Edgeworks Blog</a></li>';
                                }
      });
    }
    function EventFeed() {
      var feed = new google.feeds.Feed("http://edgeworksclimbing.com/
blog/feed/");
                  feed.setNumEntries(10);
      feed.load(function(result) {
        if (!result.error) {
                                  var container =
document.getElementById("event-headline");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var date = new Date(entry.publishedDate);
                                                date =
date.toDateString().substr(4);
                                                var eventcategory =
entry.categories;
 
if(eventcategory.indexOf("Events") != -1) {
                                                                var li
= document.createElement("li");
 
li.className = "rss-item";
 
li.innerHTML = '<a class="rss-item" href="' + entry.link + '"
target="_self">' + entry.title + '</a><br>';
 
li.innerHTML += '<a class="rss-date" href="' + entry.link + '"
target="_self">' + date + '<cite class="rss-author"> by ' +
entry.author + '</cite></a> ' + entry.categories + '<br>';
 
li.innerHTML += '<a class="rss-snippet" href="' + entry.link + '"
target="_self">' + entry.contentSnippet.truncate(50) + '</a>';
 
container.appendChild(li);
                                                }
          }
        } else {
                                                var container =
document.getElementById("event-headline");
                                    container.innerHTML = '<li><a
href="http://www.edgeworksclimbing.com/blog";>Edgeworks Blog</a></li>';
                                }
      });
    }
</script>

-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
http://groups.google.com/group/google-ajax-search-api?hl=en_US
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

Reply via email to