• Resolved seldomstatic

    (@seldomstatic)


    After reading the following two posts…

    https://www.ads-software.com/support/topic/94468
    https://www.ads-software.com/support/topic/73410

    …I came up with the following code to output the latest RSS headline with a time stamp and short excerpt followed by four headlines only (no excerpt or timestamp).

    <?php require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('https://www.website.com/rss.xml');
    for($i=0;$i<1;$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>'.$pubdate.'</i>
    <br>'.$item['description'].'<a href="'.$item['link'].'">
    more...</a></p>';
    }
    <?php require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('https://www.website.com/rss.xml');
    for($i=1;$i<5;$i++) {
    $item=$rss->items[$i];
    echo '<li><a href="' . $item['link'] . '" title="' . $item['title'] . '">' . $item['title'] . '</a></li>';
    }
    ?>

    This spits out the following:

    RSS Latest Headline
    – time stamp
    – excerpt
    2nd Most Recent Headline

    5th Most Recent Headline

    Is there anyway to combine the two fetch_rss statements so that I don’t have to call the RSS feed twice but still achieve the same output?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I combine the following fetch_rss statements?’ is closed to new replies.