Forums

fetch_rss url problem (6 posts)

  1. Hitokiri
    Member
    Posted 3 years ago #

    Hi
    I´m using fetch_rss function to display some headlines of other blogs at the bottom of my blog.
    I´m using the function as explained on the wiki:
    <?php
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('http://example.com/rss/feed/goes/here');
    echo '

    ';
    ?>

    and everything seems OK

    But when I click on a headline, and I´m supossed to go to the articles post, URL appears wrong. I get something like this:
    http://labs.valechumbar.com/\%22http://feeds.feedburner.com/~r/Muyriver/~3/41656566/\%22

    The first http:// is my blog (where the fetch_rss actually is), and the second one the rss blog where I´m supossed to be linked to.
    When I click there I just return to my own blog, not going to the destination one

    Any ideas on how to fix this?

    Thanks in advance

  2. Otto42
    Moderator
    Posted 3 years ago #

    Something is wrong with your code. You need to post *exactly* what your code looks like, instead of posting the wiki example again.

    Also, when you post code, put it between backticks (that's the character below the tilde ~ ) so that we can actually see it.

  3. Hitokiri
    Member
    Posted 3 years ago #

    :s I didn´t realize i posted the code wrond
    There it goes again:

    <?php
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('http://feeds.feedburner.com/Muyriver');
    echo '<ul>';
    for($i=0;$i<5;$i++) {
    $item=$rss->items[$i];
    echo '<li><a href=\"' . $item['link'] . '\" title=\"' . $item['title'] . '\">' . $item['title'] . '</a></li>';
    }
    echo '</ul>';
    ?>

  4. Otto42
    Moderator
    Posted 3 years ago #

    Ah. Okay. I was not aware that the wiki had screwed up the backslashes. All those backslashes in the echo line... You don't need 'em.

    Try this code:

    <?php
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('http://feeds.feedburner.com/Muyriver');
    echo '<ul>';
    for($i=0;$i<5;$i++) {
    $item=$rss->items[$i];
    echo '<li><a href="' . $item['link'] . '" title="' . $item['title'] . '">' . $item['title'] . '</a></li>';
    }
    echo '</ul>';
    ?>

  5. Hitokiri
    Member
    Posted 3 years ago #

    Great!

    Now it workd perfectly. We should correct the wiki

    Thank you very much Otto

  6. Otto42
    Moderator
    Posted 3 years ago #

    Okay, I modified the Wiki. Appearantly, the wiki always adds backslashes to double quote marks like that. Annoying.

Topic Closed

This topic has been closed to new replies.

About this Topic