<?php
function url_fetcher(){
$pageURL = \'http\';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
//echo $pageURL;
$str = explode(\'/\' ,$pageURL);
//print_r($str);
$str1 = $str[3];
echo $str1.\'<br \\>\';
$str2 = explode("-", $str1);
$cat = $str2[0];
echo $cat.\'<br \\>\';
$dog = $str2[2];
echo $dog.\'<br \\>\';
}
add_shortcode(\'url_fetch\',\'url_fetcher\');
?>
在所需位置添加快捷码[\'url\\u fetch\']。但请确保您的url的页面名称由连字符(“-”)分隔。特别是猫对狗或a对b。