Skip to content

Instantly share code, notes, and snippets.

@dipakcg
Created September 5, 2014 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dipakcg/84d25d4447e4b9ad0578 to your computer and use it in GitHub Desktop.
Save dipakcg/84d25d4447e4b9ad0578 to your computer and use it in GitHub Desktop.
WordPress - Pass URL (with ? and &) to shortcode_atts in shortcode function
// Add following code into functions.php of WordPress theme
function willhill_text($atts) {
extract( shortcode_atts( array(
"xmlurl"=>'http://'),
$atts
)
);
$str_format = str_replace(array("&","&"), "&", $xmlurl);
$rss = simplexml_load_file(esc_url_raw($str_format));
print_r($rss);
}
add_shortcode('willhill_text_link', 'willhill_text');
// Add the following shortcode in Post / Page
[willhill_text_link xmlurl="http://cachepricefeeds.williamhill.com/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=313&marketSort=--&filterBIR=N"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment