Php WordPress编码和内容摘录

Php WordPress编码和内容摘录,php,wordpress,Php,Wordpress,因此,我编写了一个函数来处理摘录,但只用于首页 http://stevefleming.co.uk/ 功能是 function excerpt_filter2($limit) { $content = get_the_content(); $content = preg_replace("/<img[^>]+\>/i", "", $content); $excerpt = explode(' ', $content, $limit); if (count($excerpt)

因此,我编写了一个函数来处理摘录,但只用于首页

http://stevefleming.co.uk/
功能是

function excerpt_filter2($limit) {

$content = get_the_content();
$content = preg_replace("/<img[^>]+\>/i", "", $content);
$excerpt = explode(' ', $content, $limit);
if (count($excerpt)>=$limit) {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt) . "...&nbsp;<a href='". get_permalink(the_ID()) ."'> continue reading</a>";
} else {
    $excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
echo $excerpt;
}
函数摘录过滤器2($limit){
$content=获取内容();
$content=preg\u replace(“/]+\>/i”,”,$content);
$extract=爆炸(“”,$content,$limit);
如果(计数($摘录)>=$limit){
数组_pop($摘录);
$EXECRPT=内爆(“,$EXECRPT)。”;
}否则{
$EXECRPT=内爆(“,$EXECRPT”);
}
$EXECRPT=预替换('\[^\]*\]`,''.$EXECRPT);
echo$摘录;
}
正如您在首页上看到的,问题在于它一直将post id附加到文本的前面

我试着调试代码,并在调用内爆之前转储$EXECRPT数组,以检查id是否以某种方式放置在数组中。。。事实并非如此

我不知道邮政id是如何到达那里的

有什么想法吗

Steve

函数
The_ID()
自动输出结果。更改此行:

$excerpt = implode(" ",$excerpt) . "...&nbsp;<a href='". get_permalink(the_ID()) ."'> continue reading</a>";
$execrpt=内爆(“,$execrpt”)。"... ";
致:

$execrpt=内爆(“,$execrpt”)。"... ";
查看更多信息,Wordpress通常有一个替代功能,它不会以以下形式输出结果:
get.*

您的代码在这里

$excerpt = implode(" ",$excerpt) . "...&nbsp;<a href='". get_permalink(the_ID()) ."'> continue reading</a>";
这将显示帖子的id,因此请尝试将其更改为

get_the_ID()

希望这就是你所面临的。:)干杯

身份证
->
获取身份证
谢谢!我知道这很简单:)谢谢你的回复,汤姆刚刚把你推到了帖子上,但我真的很感激。
the_ID()
get_the_ID()