Title: Error with an old plugin using count() function
Last modified: October 27, 2019

---

# Error with an old plugin using count() function

 *  Resolved [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/)
 * Hey…
 * I need to keep using an old plugin that creates an is_child function, and there’s
   a group of code that’s throwing an error and I’m desperately someone out there
   can explain it to me and how to fix the error that was referring to the count
   function on the first line?
 *     ```
       		while( count( $allCats ) != 0 ) {
       			if( in_array( $ofParent, $allCats ) ) { return true; }
       			else { $allCats =  is_child_getParents( $allCats ); }
       		}
       ```
   
 * I’d be exceedingly grateful.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/#post-12069193)
 * What is the name of the plugin?
 *  Thread Starter [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/#post-12069211)
 * Ryan’s Useful Options.
 * I took an old plugin called is_child and integrated into a plugin that I use 
   on some client sites because I was sick and tired of copying and pasting. Figured
   I’d make a plugin.
 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/#post-12070051)
 * No guarantees, but you can probably get it to work by changing this line:
 * `while( count( $allCats ) != 0 ) {`
 * to this:
 * `while( !empty($allCats) ) {`
 * Starting with PHP 7.2, the `count()` function requires the element to be something
   that is countable (array, object, etc). Previous versions of PHP allowed pretty
   much anything…with oftentimes unexpected results.
 *  Thread Starter [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/#post-12072955)
 * That nailed it. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Error with an old plugin using count() function’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/error-with-an-old-plugin-using-count-function/#post-12072955)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
