in_array() 期望参数 2 为数组,Classipress 中给出的字符串

use*_*087 3 php arrays wordpress

我正在使用Classipress themewordpress,并且我正在尝试将我的特色广告粘贴到类别中。

我发现一个返回此错误的代码:

Warning: in_array() expects parameter 2 to be array, string given in loop-ad_listing.php on line 26
Run Code Online (Sandbox Code Playgroud)

要使用顶部粘性代码,我必须编辑两个页面并插入两个代码,然后我将发布错误部分:

第一的:loop-ad_listing.php

代码1:

global $postisfeatured;
global $featurePostArray;

if ($postisfeatured == "1") 
    array_push($featurePostArray, $post->ID);

if (in_array($post, "ID", $featurePostArray) && $postisfeatured != "1") 
    echo '<div class="hide">';
Run Code Online (Sandbox Code Playgroud)

代码2:

if ($postisfeatured != "1") {
    appthemes_after_endwhile();
    $postisfeatured = "";
}
Run Code Online (Sandbox Code Playgroud)

那行:if (in_array($post,"ID",$featurePostArray) && $postisfeatured != "1") { 是错误。

and*_*rew 7

的签名in_array看起来像:

  in_array($needle, $haystack, $strict = FALSE);
Run Code Online (Sandbox Code Playgroud)

在哪里:

needle是您正在搜索的字符串、整数、资源等。

haystack是您要搜索的数组

strict(可选)如果(或不)匹配的项目应该相同(===