WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Fetching a feed giving wrong url

[Resolved] Fetching a feed giving wrong url

  • Hi!

    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/http://www.vattenmyndigheterna.se/Sv/nyheter/2012/Pages/information-om-driftstorningar-pa-webbplatsen.aspx

    Below is the code I use for the fetching.

    <?php include_once(ABSPATH.WPINC.'/feed.php');
    $rss = fetch_feed('http://www.vattenmyndigheterna.se/_layouts/LST/rss.aspx?CatSubs=cat_SO&CTypeId=0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390028F91F325164A04A99A657904587918502&SortFieldId=45879185-d6c1-4a8d-b726-7108fe81e536&Title=L%C3%A4nsstyrelsen+-+Nyheter&Desc=Nyhetsarkiv%C2%A4Nyhetsarkiv_RSSBeskrivning&Lang=Sv&Source=NewsListDataContol');
    $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>';
    else
    // 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() ); ?>'
    title=''>
          <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!
    /Richard

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="http:www.vattenmyndigheterna.se/Sv/nyheter/2012/Pages/information-om-driftstorningar-pa-webbplatsen.aspx" 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 ‘[Resolved] Fetching a feed giving wrong url’ is closed to new replies.
Skip to toolbar