Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Support request] PHP Warning: count(): countable in wp-includes/post-template.php on line 284

Home Forums Support [Support request] PHP Warning: count(): countable in wp-includes/post-template.php on line 284

Home Forums Support PHP Warning: count(): countable in wp-includes/post-template.php on line 284

  • This topic has 2 replies, 2 voices, and was last updated 3 years ago by Tom.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #559297
    phild

    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!

    GeneratePress 2.0.2
    #559399
    phild

    // this prior to the original line is a better solution:

    if (empty($pages)) $pages = [];

    #559522
    Tom
    Lead Developer
    Lead Developer

    Where are you seeing this code in GeneratePress?:

    if ( $page > count( $pages ) )

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.