Created
September 5, 2014 19:04
-
-
Save dipakcg/84d25d4447e4b9ad0578 to your computer and use it in GitHub Desktop.
WordPress - Pass URL (with ? and &) to shortcode_atts in shortcode function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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