skip to Main Content

i’ve a problem with WordPress. This is the error message: PHP 7.2 Warning count(): Parameter must be an array or an object that implements Countable /web/htdocs/www.firenzeflowershow.com/home/wp-content/themes/wpex-elegant/functions/meta/init.php on line 750

> elseif ( is_array( $meta_box['pages'] ) && count( $meta_box['pages']
> === 1  ))             $type = is_string( end( $meta_box['pages'] ) ) ? end( $meta_box['pages'] ) : false;

3

Answers


  1. Please try if this works:

    elseif ( is_array( $meta_box['pages'] ) && count($meta_box['pages'])
    >= 1  )
    
    Login or Signup to reply.
  2. Try:

    elseif ( is_array( $meta_box['pages'] ) && count( $meta_box['pages'] )
    === 1)             $type = is_string( end( $meta_box['pages'] ) ) ? end( $meta_box['pages'] ) : false;
    

    Your code did not work because === 1 was inside the count() function call: count($meta_box['pages'] === 1), and a comparison returns a bool. Here, I have changed it to count($meta_box['pages']) === 1 which gets the number of elements in the array, and checks if it returns 1.

    Login or Signup to reply.
  3. The closing parenthesis of count is in the wrong position. You are actually passing a boolean to the function, because "$meta_box[‘pages’] === 1" will return true or false. Your code should be:

    count($meta_box['pages']) === 1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search