Get warning: count(): Parameter must be an array… after upgrading to PHP7

Forums › Forums › Search & Filter Pro › Get warning: count(): Parameter must be an array… after upgrading to PHP7

Viewing 8 posts – 1 through 8 (of 8 total)
  • Anonymous
    #227223

    The full code the warning is refering to (among other places, but always same structur):
    It’s a part of a template that displays a list of projects, created with Search&Filter Pro.

    <?php //non clickable
    $terms = get_the_terms($post->ID, ‘year_of_completion’);
    $count = count($terms);
    if ($count > 0 && ! empty( $terms ) && ! is_wp_error( $terms) ){
    foreach ( $terms as $term ) {
    echo $term->name ;
    }
    }

    I am sorry to say I have no idea how to solve it.. Have tried several things but seems to make things rather worse than better.

    Thanks for your help.

    Best,

    Kirsten

    Trevor
    #227234

    Is the error in the front or back end?

    Warnings are just that, only warnings. They should not be appearing on a production (i.e. visible to the public) sites. You should set the PHP variable display_errors to OFF (per the PHP manual).

    What version of our plugin are you using, as I am sure we had this issue many versions ago with PHP 7.2 and higher?

    Our current version is 2.4.6

    Anonymous
    #227320

    Hi Trevor,
    the warning appears in the front end, it’s still on staging (we were testing PHP 7.3).
    Running the WordPress 5.3 and version 2.4.6 of Search&Filter Pro
    I do realize that warning is “just” a warning, but I am kind of worried it might turn into an error in the near future… And would be happy to be able to fix it. 😉
    Best
    Kirsten

    Trevor
    #227325
    This reply has been marked as private.
    Anonymous
    #227360

    Sounds great, thanks, Trevor! I’ll try it immediately.
    Best,
    Kirsten

    Trevor
    #227371

    Ok. I will wait to hear from you.

    Anonymous
    #227375

    Hi Trevor,
    thanks for trying to help!
    Unfortunately it did not fix my problem, but meanwhile I gained some insights on how to work this out PHP wise.
    Looks like I found a solution myself…
    Thanks so much for your support!

    Best,

    Kirsten

    Trevor
    #227377

    Thanks for letting me know. I will close this thread for now.

Viewing 8 posts – 1 through 8 (of 8 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.