Hello-
When I first started with GP I was having pagination issues and I believe on of the moderators gave me the following to use to correct the problem
function remove_page_from_query_string($query_string)
{
if ($query_string[‘name’] == ‘page’ && isset($query_string[‘page’])) {
unset($query_string[‘name’]);
$query_string[‘paged’] = $query_string[‘page’];
}
return $query_string;
}
add_filter(‘request’, ‘remove_page_from_query_string’);
Fast forward to 2023, I’m getting the following error’s per my host:
2023/02/22 03:27:28 [error] 123236#123236: *261645 FastCGI sent in stderr: “PHP message: PHP Warning: Undefined array key “name” in /www/XXXXXXXXX/public/wp-content/plugins/code-snippets/php/snippet-ops.php(505) : eval()’d code on line 3″ while reading response header from upstream, client: 35.236.17.54, server: http://www.XXXXXX.com, request: “HEAD /XXXXXXXXXX/ HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php8.0-fpm-XXXXXXX.sock:”, host: “XXXXXXXXX”, referrer: “https://XXXXXXXXXXX”
The plugin author suggested I update the code to the following. My question is this; does this look ok to you, any potential issues I should be aware of? Thanks!
add_filter( ‘request’, function ( $query_string ) {
if ( isset( $query_string[‘page’], $query_string[‘name’] ) && ‘page’ === $query_string[‘name’] ) {
unset( $query_string[‘name’] );
$query_string[‘paged’] = $query_string[‘page’];
}
return $query_string;
} );