Archived topic
PHP Warning: count(): countable in wp-includes/post-template.php on line 284
2 replies · Started by phild on April 24, 2018
Hi,
Getting a countable warning on first page of all sites that use generatepress with php 7.2
PHP Warning: count(): Parameter must be an array or an object that implements Countable in /www/wordpress/wp-includes/post-template.php on line 284
>php -v
PHP 7.2.4
GeneratePress Version: 2.0.2
// original code
if ( $page > count( $pages ) )
// fixes issue
if ( $page > empty($pages) ? 0 : count( $pages ) ) // if the requested page doesn't exist`
Thanks!
// this prior to the original line is a better solution:
if (empty($pages)) $pages = [];
Where are you seeing this code in GeneratePress?:
if ( $page > count( $pages ) )