WordPress custom page type pagination 404

During development if you get a 404 when trying to paginate with a custom post type there may be a simple explanation.

If there is a page with the same name as the custom post type the permalink rewrite rules will get confused e.g. a page called books and a custom post type with post_type key books. The solution is to name the custom post type key with the singular version, then it’s fine.

Prevent WordPress showing notice errors

When you are working with an older site it may be necessary to prevent notice level errors from appearing in the error log so that you aren’t swamped with too many messages.

Adding code to wp-config.php doesn’t work because WordPress itself tries to set the error level.

Instead create a ‘must use’ plugin and add the following:

error_reporting(E_ALL & ~E_NOTICE);

CodeIgniter 4 using Request object in view

It can be useful to use the request object in a view to retrieve input, this was easy with CodeIgniter 3 but with CodeIgniter 4 the documentation doesn’t cover this.

Add this to the top of your view

<?php
$request = \Config\Services::request();
?>

Then you can use the request methods like this

<input type="hidden" id="score" name="score" value="<?=$request->getVar('score')?>">