如何为 "post don't have featured image" 编写 if 语句

How to write if statement for "post don't have featured image"

如果 post 没有特色图片,我该如何告诉 Wordpress 插入内容。我不能使用 if-else。我只需要使用if,所以如果"post don't have featured image"然后我会添加做什么。

我在想:

<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail(' false '))  ) { ?>

但上面的方法不起作用...

以上代码将在特定页面进入循环。

请注意我完全是菜鸟,也不是编码员,所以请给我详细的解释如何做某事。非常感谢。

对于一个非编码人员来说,你在路上很火爆。假设您在 THE LOOP 中,您可以使用 :

<php if(!has_post_thumbnail()){ 
     //Your stuff here
}?>

如果您不在 THE LOOP,您只需传递 post 的 ID

<php if(!has_post_thumbnail($post_id)){ 
     //Your stuff here
}?>

!符号用于 "not",表示如果 post 没有 post 缩略图。