• Resolved WPChina

    (@wordpresschina)


    I am fetching an RSS2.0 feed from a wordpress blog and I want to integrate it into my site. I am using pubDate to try to get the date of the feed on my site, but pubDate seems not to work. I can get the title and the URL, but not the date.

    Anyone know how to print the date for posts from the fetched feed? In addition, is it possible to capture other info from that fetched feed when using fetch_rss?

    Tks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try ‘pubdate’, not ‘pubDate’.

    Thread Starter WPChina

    (@wordpresschina)

    Great, fixed… almost….

    It now prints something like this: “Thu, 16 Nov 2006 01:47:42 +0000”

    But is it possible to only get it to print “Thu, 16 Nov 2006”?

    Thank you Kafkaesqui!

    The simplest way is, since the format is always the same and the character count shouldn’t vary, is to parse it using the PHP substr() function.

    Assuming each rss item is held in $item in your code:

    $pubdate = substr($item['pubdate'], 0, 16);

    Thread Starter WPChina

    (@wordpresschina)

    Sorry to bother you, but I can’t figure out where to add that substr. I am using different variations of the following and putting it all different places, but it seems not able to print out the correct info:

    <?php
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('http://www.website.com/feed/');
    for($i=0;$i<5;$i++) {
    $item=$rss->items[$i];
    $pubdate=substr($item['pubdate'], 0, 16);
    echo '<p><a href="'.$item['link'].'" title=" '.$item['title'].'">
    <b>'.$item['title'].'</b></a><br><i>'.$item['pubdate'].'</i>
    <br>'.$item['description'].'<a href="'.$item['link'].'">
    more...</a></p>';
    }
    ?>

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    ...<i>'.$item['pubdate'].'</...

    Change that to:
    ...<i>'.$pubdate.'</...

    Thread Starter WPChina

    (@wordpresschina)

    ahhhhhh…. works well…. tks!

    I will now mark this Resolved!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I include date on fetch_rss?’ is closed to new replies.