Hide the page you’ve set to show Posts in WP Admin

One of my many annoyances with WordPress is how you need to create a page, and assign that to be the Posts archive page, if you want a static home page and Posts elsewhere. This usually means having a page in WP with the editor saying something like “Don’t delete this page, it’s pretty important!”.

I found this answer on SO, and adapted it to suit my needs.

function origin_hide_posts_page_in_admin($query) {
if (!$query->is_admin() && !$query->is_main_query()) :

global $typenow;

if ('page' == $typenow) {
$query->set('post__not_in', array(get_option('page_for_posts')));
add_action('pre_get_posts', 'origin_hide_posts_page_in_admin');

So, now the page I assigned to be the Posts page is now hidden. Much better! If I ever need it again, just comment out that function.