Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使我的WordPress slug成为字符串数据?_Php_Wordpress - Fatal编程技术网

Php 如何使我的WordPress slug成为字符串数据?

Php 如何使我的WordPress slug成为字符串数据?,php,wordpress,Php,Wordpress,我目前正在为我的WordPress站点收集来自SoundCloudAPI的数据,我正在尝试将SoundCloudAPI中的永久链接部分设置为WordPress站点中的slug 下面是我收集永久链接的一些代码(不确定为什么需要它,但我确信如果我没有任何代码,我会得到一些热量) $client_ID='xxxx'; $profilename=$\u GET['pr']; $sc=curl_init(); curl_setopt($sc,CURLOPT_URL,'http://api.soundcl

我目前正在为我的WordPress站点收集来自SoundCloudAPI的数据,我正在尝试将SoundCloudAPI中的永久链接部分设置为WordPress站点中的slug


下面是我收集永久链接的一些代码(不确定为什么需要它,但我确信如果我没有任何代码,我会得到一些热量)

$client_ID='xxxx';
$profilename=$\u GET['pr'];
$sc=curl_init();
curl_setopt($sc,CURLOPT_URL,'http://api.soundcloud.com/users/“.$user\u ID.'/tracks?client\u ID=”.$client\u ID.');
curl_setopt($sc,CURLOPT_头,0);
curl_setopt($sc,CURLOPT_RETURNTRANSFER,true);
$output=curl_exec($sc);
卷曲关闭($sc);
$content=json_decode($output,true);
打印$content[0]['permalink'];
/*不太重要,所以被评论掉了。
打印“”;
打印(内容);
打印“”;
*/
上述代码显然返回了
pr
变量中与艺术家集相关的所有曲目数据



如果你看上面的例子,我已经打印出了
permalink
,在本例中,它的内容是
stop-the-car-w-horsehead-prod-smokeasac
。所以我希望我的网站的url看起来像这样。而不是默认的WordPressslug。

我认为您可能需要覆盖slug的默认处理程序。如果我理解正确,您希望有指向特定页面的动态链接。如果您不想在数据库中创建每个url,您必须查看哪个文件负责重定向,并可能进行corehack来解析对Soundcloud的curl请求的结果


希望这有帮助。

print”http://www.example.com/track/“$content[0]['permalink']
@Anant不是我想要的,我希望我网站的实际slug是与标准
?p=4918
变量对应的url。但仅在我的示例中显示的
曲目
类别中。
$client_ID = 'xxxx'; 
$profilename = $_GET['pr'];

$sc = curl_init();
curl_setopt($sc, CURLOPT_URL, 'http://api.soundcloud.com/users/'.$user_ID.'/tracks?client_id='. $client_ID.'');
curl_setopt($sc, CURLOPT_HEADER, 0);
curl_setopt($sc, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($sc);
curl_close($sc);
$content = json_decode($output, true);
print $content[0]['permalink'];

/* not really important so commented out.

    print '<pre>';
    print_r($content);
    print '</pre>'; 

*/