Support » Fixing WordPress » Fetching a feed giving wrong url

  • Resolved Knut23



    I am trying to fetch a feed from another site. The fetching works well, but WordPress adds my own website url in the beginning of the link to the feed post. Links looks like this “http://localhost/wp2/

    Below is the code I use for the fetching.

    <?php include_once(ABSPATH.WPINC.'/feed.php');
    $rss = fetch_feed('');
    $maxitems = $rss->get_item_quantity(3);
    $rss_items = $rss->get_items(0, $maxitems);
          <?php if ($maxitems == 0) echo '<li>Något har blivit fel.</li>';
    // Loop through each feed item and display each item as a hyperlink.
    foreach ( $rss_items as $item ) : ?>
          <span class="datum-news"><?php echo $item->get_date('Y-m-d'); ?></span>
          <h4><?php echo $item->get_title('external-link', true); ?></h4>
          <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
          <p><?php echo wp_trim_words($item->get_description(), 15); ?> </p>
          </a> <br />
          <?php endforeach; ?>

    The url for the feed is very long and contains special characters. The “%C3%A4” in “L%C3%A4nsstyrelsen” is the swedish letter “ä” and the “%C2%A4” is the currency sign “¤”.
    Could these characters have anything to do with the change in post url? Cause I have tried using other feeds, without special characters in their url’s, and they work…

    Any suggestions of what might be the solution to this?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I just had look at the html source of my wordpress generated page and saw that the link to the external rss post is wrong. It omits the // after http:.

    <span class="datum-news">2012-09-27</span>
          <h4>Information om driftstörningar på webbplatsen</h4>
          <a href="" title="">
          <p>Kortare avbrott kan förekomma på Vattenmyndigheternas webbplats under helgen den 28-30 september. </p>
          </a> <br>

    But I don’t know if this is an error on my part or on the rss flow. If I had to guess I would say rss flow, though.

    Anyone with better knowledge?

    PS If any of you guys know Swedish, you will see that the rss post above talks about problems with the server. This is not the source of my problem. My problem has been going on for a longer period… DS

    Further research reveals that the source of the problem lies at the source of the external rss flow. Nothing wrong with wp fetch-feed.

    I didn’t catch it cause I was using Firefox to view the feed and it was able to get the links right, even though they were in fact missing the // in the url. Switching to IE found the culprit.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fetching a feed giving wrong url’ is closed to new replies.