0

There is a single line of code that's stopping me from upgrading my site's PHP. I'm not a programmer, but I'm hoping that since it's only one line, it might be something I can fix. The error is coming up as "PHP Fatal error: Uncaught Error: Call to undefined function" and is citing the following line of code as the culprit:

add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 8;' ), 20 );

Anyone have any idea of how to get this working properly?

eglease
  • 2,445
  • 11
  • 18
  • 28
LN86
  • 1
  • https://www.php.net/manual/en/function.create-function.php - removed as of PHP 8 – ADyson Aug 22 '23 at 14:21
  • `PHP Fatal error: Uncaught Error: Call to undefined function`...this clearly isn't the full error message, it's missing the bit which tells you _which_ function is undefined. Luckily it was easy to guess, but in future please don't truncate, abbreviate, paraphrase or otherwise alter error messages when reporting them. Thanks. – ADyson Aug 22 '23 at 14:23

1 Answers1

0

Try this:

add_filter( 'loop_shop_per_page', static function ( $per_page ) {
    return 8;
}, 20 );
Caleb
  • 1,058
  • 1
  • 7
  • 18