Php Wordpress post循环未按预期工作
我使用的主题使用博客页面在博客页面上显示其所有内容,而不是摘录,然后当我点击帖子时,我想显示全部内容 我正在使用以下代码:Php Wordpress post循环未按预期工作,php,wordpress,loops,if-statement,Php,Wordpress,Loops,If Statement,我使用的主题使用博客页面在博客页面上显示其所有内容,而不是摘录,然后当我点击帖子时,我想显示全部内容 我正在使用以下代码: $postId = get_the_ID(); $ex = the_excerpt(); if($postId == 19){ echo $ex; } else{ echo $content; } 博客页面位于post=19 我希望
$postId = get_the_ID();
$ex = the_excerpt();
if($postId == 19){
echo $ex;
}
else{
echo $content;
}
博客页面位于post=19
我希望只有摘录显示在博客页面上,内容显示在帖子页面上。然而,两者都显示了这一点。同样,如果我在if语句中更改数字19也没关系。谁能看出我错在哪里
编辑所做的更改、屏幕截图:
函数,如
the_extract()
仅在循环内部或调用函数the_post()后可用
您可能只想在index.php中显示
while (has_posts()) {
the_post();
the_excerpt();
}
在single.php中,您可能希望显示整个内容
if(has_posts()) {
the_post();
the_content();
}
您需要使用
the_extract()条件内的代码>表示您希望显示摘录,但如果您希望获取摘录的值但不希望直接显示,则必须使用get_the_extract()代码>所以您需要更改
$ex = the_excerpt();
to
$ex = get_the_excerpt();
内容()的情况也是如此
希望它能对你有所帮助。谢谢你,伙计,这在博客页面上效果很好,但是现在每个博客页面都会显示摘录和内容。你能发送截图吗?谢谢你的帮助mate@jrarama,_content()
本身用于输出内容,因此它不需要回显_content()代码>。这同样适用于摘录()
$ex = the_excerpt();
to
$ex = get_the_excerpt();