Disable Posts for a Pages-Only Site
Hides the built-in Posts type everywhere in the admin and on the front end, for brochure sites that only use pages.
Opens WPIDE on
Code
add_filter( 'register_post_type_args', function ( $args, $post_type ) {
if ( 'post' !== $post_type ) {
return $args;
}
return array_merge( $args, array(
'public' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'show_ui' => false,
'show_in_menu' => false,
'show_in_admin_bar' => false,
'show_in_nav_menus' => false,
) );
}, 10, 2 );
add_action( 'wp_dashboard_setup', function () {
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
}, 99 );
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'new-post' );
}, 999 );
Notes
Existing posts return 404, so set a static homepage in Settings > Reading first.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.