Hi Michael, I tried to use your guide and got a 404 error.
I spent some time looking for reasons and this will happen if you are also using Elementor on the site.

The solution for me was simple. I added precedence to the last line of code.
Something like:

add_action( 'pre_get_posts', 'cptui_demo_add_post_type_to_query', 20, 2 );