• Cathy Mitchell

    (@multitalentedmommy)


    I’m using the code exactly as it says to here. and this is the warning i’m getting:

    Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/*****/blog/wp-content/themes/yellowhiteflower/yellowhiteflower/sidebar.php on line 23
    
        * No items

    I have no idea how to fix this and I can’t find a plugin to work with this either, nor more info on google. I’m truly stuck here folks – any help would be soooo appreciated.

    This is the code I’m using (from above codex page)

    <h2><?php _e('New at SAGF'); ?></h2>
    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/rss.php');
    $rss = fetch_rss('https://strawberriesareglutenfree.com/feed/');
    $maxitems = 5;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    
    <ul>
    <?php if (empty($items)) echo '<li>No items</li>';
    else
    foreach ( $items as $item ) : ?>
    <li><a href='<?php echo $item['link']; ?>'
    title='<?php echo $item['title']; ?>'>
    <?php echo $item['title']; ?>
    </a></li>
    <?php endforeach; ?>
    </ul>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Cathy Mitchell

    (@multitalentedmommy)

    Does anyone understand that error in the first code box? ANyone know of any forums/ lists that might be able to help?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Try this code instead for that line:
    $items = @ array_slice($rss->items, 0, $maxitems);

    That @ sign will make it suppress the warning.

    But the underlying problem is that the server could not get the feed at that address.

    Thread Starter Cathy Mitchell

    (@multitalentedmommy)

    this is much simpler! lol

    <?php
    include_once(ABSPATH . WPINC . '/rss-functions.php');
    wp_rss('https://strawberriesareglutenfree.com/feed', 5);
    ?>

    BUT the feed still isn’t working… I get it in my own feedreaders/ live bookmarks just fine. whaaaa???

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘fetch_rss() isn’t working’ is closed to new replies.