0

Checking the Query Monitor, it's throwing out this error,

array_key_exists(): The first argument should be either a string or an integer

which relates to this function:

public function lsx_team_scporder_get_terms_orderby( $orderby, $args ) {
    if ( is_admin() )
        return $orderby;

    $tags = $this->get_lsx_team_scporder_options_tags();

    if ( ! isset( $args['taxonomy'] ) )
        return $orderby;

    $taxonomy = $args['taxonomy'];
    if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 )
        $taxonomy = $taxonomy[0];
    if ( ! array_key_exists($taxonomy, $tags ) )
        return $orderby;

    $orderby = 't.lsx_team_term_order';
    return $orderby;
}

Why is it throwing out that error?

1
  • I got this error today (2020-03-27) after updating WordPress to 5.3.2 (using theme "Responsive"). It happened on submitting updates to an existing blog post. It seems to be theme specific (and updating to the new version of the theme released today did not fix the problem). The workaround is to change to another theme (at least during adding/changing content) - I used the official "Twenty Twenty" theme. Mar 27, 2020 at 22:40

1 Answer 1

0

From the php manual the array_key_exists() function takes as first argument "any value possible for an array index.", again looking up for arrays in the docs we can get that "The key can either be an integer or a string. The value can be of any type.", which also corresponds to the error you see from the Query Monitor.

Meaning that the $taxonomy variable that is passing to the array_key_exists() is not either a string or integer.

You can debug the $taxonomy variable, by making a var_dump($taxonomy);.

Hope, that helps.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.