in_array()期望参数2为数组,在Classipress中给出的字符串 [英] in_array() expects parameter 2 to be array, string given in Classipress

查看:41
本文介绍了in_array()期望参数2为数组,在Classipress中给出的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Classipress主题用于wordpress,并且试图将我的精选广告粘贴在类别上。

I'm using Classipress theme for wordpress, and I'm trying to sticky my featured ads on the on in categories .

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

I found a code that is return this error:

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

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

To use the sticky on top code, I had to edit two pages and insert two codes and I'll post the error part:

首先: loop-ad_listing.php

global $postisfeatured;
global $featurePostArray;

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

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



代码2:



Code2:

if ($postisfeatured != "1") {
    appthemes_after_endwhile();
    $postisfeatured = "";
}

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

That line: if (in_array($post,"ID",$featurePostArray) && $postisfeatured != "1") { is the error.

推荐答案

in_array 的签名如下:

  in_array($needle, $haystack, $strict = FALSE);

其中:

needle 是您要搜索的字符串,整数,资源等。

needle is the string,int,resource etc which you're searching for.

干草堆是您要搜索的数组

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

strict (optional) If (or not) the matched item should be identical (===)

这篇关于in_array()期望参数2为数组,在Classipress中给出的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆