WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] RSS from WP in iframe on other sites (2 posts)

  1. timk
    Member
    Posted 6 years ago #

    I'm trying to make a badge (copy and paste code - html/css only) that users can add to their site (WP.com, Blogspot, Myspace, whatever) that will display an RSS feed from a WP 2.5 blog inside a badge similar to the SpringWidgets, which are embedded Flash objects, I believe. I have a few examples at http://timbury.org/ that are working which load all the code into the sidebar. The one example which is broken is where I try to load a separate php file into an iframe. As you can see, I get the message: "Fatal error: Call to undefined function do_action() in /var/www/timbury.org/wp-includes/rss.php on line 18"

    This call is working on the same page in the other 3 examples. For some reason, the code in the iframe executes in a different namespace? The environment isn't the same. What am I doing wrong?

    Then, if this can be made to work, the next step is moving the file called from the iframe to the remote server.

    I don't know if I've succeeded in communicating what I'm trying to do.

    The code that works is this:

    <!-- AnthillWidget v0.1 | WordPress | summary | Author: timbury -->
    <?php include_once(ABSPATH . WPINC . '/rss.php');
    $rss = fetch_rss('http://www.cre8buzz.com/anthill/?feed=rss2');
    $maxitems = 5;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    <div id="AnthillWidget" style="font:12px arial;width:250px;border:#507AA5 solid 5px;color:#999;background:#fff url(http://timbury.net/anthill_feed_header.gif) top center no-repeat; padding-top:50px;text-decoration:none;">
    <ul style="border-top:#999 solid 1px;border-bottom:#999 solid 1px;">
    <?php if (empty($items)) echo '<li>No items</li>';
    else
    foreach ( $items as $item ) : ?>
    <li><a style="color:#507AA5;text-decoration:underline;" href='<?php echo $item['link']; ?>'
    title='<?php echo $item['title']; ?>'>
    <?php echo $item['title']; ?>
    </a><br /><?php echo $item['description']; ?></li>
    <?php endforeach; ?>
    </ul><br />&nbsp;&copy;2008 cre8Buzz
    </div>

    The code pair that fails is this in the sidebar:

    <!-- AnthillWidget v0.1 | WordPress | summary | Author: timbury -->
    <div id="AnthillWidget" style="font:12px arial;width:250px;border:#507AA5 solid 5px;color:#999;background:#fff url(http://timbury.net/anthill_feed_header.gif) top center no-repeat; padding-top:50px;text-decoration:none;">
    <center><iframe align=center width=230 height=250 scrolling=auto src="<?php bloginfo('stylesheet_directory'); ?>/iframe.php"></iframe>
    </div>

    And this in iframe.php:

    <?php include_once('/var/www/timbury.org/wp-includes/rss.php');
    $rss = fetch_rss('http://www.cre8buzz.com/anthill/?feed=rss2');
    $maxitems = 5;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    
    <ul style="border-top:#999 solid 1px;border-bottom:#999 solid 1px;">
    <?php if (empty($items)) echo '<li>No items</li>'; else foreach ( $items as $item ) : ?>
    <li><a style="color:#507AA5;text-decoration:underline;" href='<?php echo $item['link']; ?>'
    title='<?php echo $item['title']; ?>'>
    <?php echo $item['title']; ?>
    </a><br /><?php echo $item['description']; ?></li>
    <?php endforeach; ?>
    </ul><br />&nbsp;&copy;2008 cre8Buzz

    I've been banging my head for two days, any help is greatly appreciated.

  2. timk
    Member
    Posted 6 years ago #

    Thanks to rmccue in the #wordpress channel on irc.freenode.net! This now works by simply adding

    <?php include_once('/var/www/timbury.org/wp-config.php');

    as the first line of iframe.php, *before* including rss.php.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags