WordPress.org

Ready to get started?Download WordPress

Forums

Function Reference/fetch rss (3 posts)

  1. ergate
    Member
    Posted 7 years ago #

    I am using the following Function Reference/fetch rss found in the codex. It works fine, right out of the box. I would like to limit the amount of entries it displays, does anybody know how to do that?

    <?php require_once(ABSPATH . WPINC . '/rss.php'); ?>
    <?php $rss = fetch_rss('http://example.com/rss/feed/goes/here'); ?>
    <ul>
    <?php foreach ( $rss->items as $item ) : ?>
    <li><a href='<?php echo $item['link']; ?>'
    title='<?php echo $item['title']; ?>'>
    <?php echo $item['title']; ?>
    </a></li>
    <?php endforeach; ?>
    </ul>
  2. drmike
    Member
    Posted 7 years ago #

    Yup :)

    It actually does this on your Dashboard's index.php file. If you're running 2.1, take a look at wp-admin/index-extra.php. Line #32's array_slice function is probably what you're looking for.

    Hope this helps,
    -drmike

  3. ergate
    Member
    Posted 7 years ago #

    I think I am missing something. I tried some variations of that I cannot get anything to work.

    I just want to display the five latest posts from one wp blog on the main page of another wp blog. I have my above code working, but it is spitting out 30+ posts.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.