Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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获取帖子缩略图_Php_Wordpress - Fatal编程技术网

Php 在插件内部无法使用wordpress获取帖子缩略图

Php 在插件内部无法使用wordpress获取帖子缩略图,php,wordpress,Php,Wordpress,我想用wordpress插件显示帖子缩略图 $thepostid包含帖子id。。。如果我这样做: $status .= $thepostid; 我得到了该职位的正确职位id 但是,如果我尝试使用该变量获取帖子缩略图,它将不起作用 $status .= get_the_post_thumbnail( $thepostid , 'medium' ); 如果我将其与正确的post id一起使用,则如下所示: $status

我想用wordpress插件显示帖子缩略图

$thepostid包含帖子id。。。如果我这样做:

            $status .= $thepostid;
我得到了该职位的正确职位id

但是,如果我尝试使用该变量获取帖子缩略图,它将不起作用

            $status .= get_the_post_thumbnail( $thepostid , 'medium' ); 
如果我将其与正确的post id一起使用,则如下所示:

            $status .= get_the_post_thumbnail( 884 , 'medium' );    
它是有效的


我不知道问题出在哪里…

那么应该显式转换类型

$status .= get_the_post_thumbnail( (int) $thepostid , 'medium' );

get_The_post_缩略图的第一个参数将$post->ID作为整数值。

是$thepostid是整数还是字符串?我猜是整数。。它与例如884的声音相呼应。。hm可能是字符串,但hm不起作用。如果获取该变量的类型不起作用,我无法在此处回显以将其放入变量$status中…它实际上不包含post ID。您确定它实际上不是包含ID的$status吗?另外,为什么不将get_ID或$post->ID传递到函数中呢?