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 “https://localhost/wp2/https://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('https://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
- The topic ‘Fetching a feed giving wrong url’ is closed to new replies.