Title: basic passing url through shortcode causing unusual problem
Last modified: August 22, 2016

---

# basic passing url through shortcode causing unusual problem

 *  [Sam](https://wordpress.org/support/users/ssharples/)
 * (@ssharples)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/basic-passing-url-through-shortcode-causing-unusual-problem/)
 * here’s my shortcode:
 * [willhill_text_link xmlurl=”[http://cachepricefeeds.williamhill.com/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=313&marketSort=–&filterBIR=N”%5D](http://cachepricefeeds.williamhill.com/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=313&marketSort=–&filterBIR=N”%5D)
 * here’s my function:
 *     ```
       function willhill_text($atts) {
          extract(shortcode_atts(array(
             'xmlurl' => '',
          ), $atts));
       $rss = simplexml_load_file($xmlurl);
       print_r($rss);
       }
   
       add_shortcode('willhill_text_link', 'willhill_text');
       ```
   
 * If you run it, you will see an xml feed outputted. But, if you simply do this:
 *     ```
       $rss = simplexml_load_file('http://cachepricefeeds.williamhill.com/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=313&marketSort=--&filterBIR=N');
       print_r($rss);
       ```
   
 * You get a different output.
 * It is as if the function is ignoring everything from ‘?action’ onwards from the
   url being passed.
 * Can anybody explain why?
 * Thanks

Viewing 1 replies (of 1 total)

 *  [Dipak Gajjar](https://wordpress.org/support/users/dipakcg/)
 * (@dipakcg)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/basic-passing-url-through-shortcode-causing-unusual-problem/#post-5250643)
 * Hi Sam,
 * You have to add line `$str_format = str_replace(array(" & # 0 3 8 ;"," & a m 
   p ;"), "&", $xmlurl);` into your function to fix this.
 * Updated function :
 *     ```
       function willhill_text($atts) {
       	extract( shortcode_atts( array(
       		"xmlurl"=>'http://'),
       		$atts
       		)
        	);
   
               // Remove spaces from " & # 0 3 8 ;"," & a m p ;"
        	$str_format = str_replace(array(" & # 0 3 8 ;"," & a m p ;"), "&", $xmlurl);
   
        	$rss = simplexml_load_file(esc_url_raw($str_format));
        	print_r($rss);
       }
       add_shortcode('willhill_text_link', 'willhill_text');
       ```
   
 * Pastie.org URL : [http://pastie.org/private/hjtfgnqsbzfanfdhumemw](http://pastie.org/private/hjtfgnqsbzfanfdhumemw)
 * I hope this helps.
 * ~ Dipak G.

Viewing 1 replies (of 1 total)

The topic ‘basic passing url through shortcode causing unusual problem’ is closed
to new replies.

## Tags

 * [RSS](https://wordpress.org/support/topic-tag/rss/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [xml](https://wordpress.org/support/topic-tag/xml/)

 * 1 reply
 * 2 participants
 * Last reply from: [Dipak Gajjar](https://wordpress.org/support/users/dipakcg/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/basic-passing-url-through-shortcode-causing-unusual-problem/#post-5250643)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
