Custom Post Type not showing in main loop

Regarding the var_dump, “courses” isn’t showing up because the var_dump is running outside of any action. So it gets triggered before the “init” action runs, which is where the post type is registered.

Regarding the main loop, I pasted your code into the default Twenty Seventeen theme’s functions.php file, and added a course via the dashboard, and it showed up on the homepage for me.