So I've been working on a WordPress site, and I need a custom post for documents, which is supposed to be registered as 'document'. I generated the code for the custom post in a plugin, Meta Box, and placed the code in my functions.php file (though while testing, I disabled Meta Box to see if it was interfering, while keeping the php it generated in functions.php). I have a template, single-document.php file, in the root of my theme (which is a child theme, if that makes a difference). But WordPress keeps defaulting to single.php, even after refreshing permalinks.
This is the code Meta Box generated to add the custom post:
function register_document() {
$args = array (
'label' => esc_html__( 'Documents', 'mb86' ),
'labels' => array(
'menu_name' => esc_html__( 'Documents', 'mb86' ),
'name_admin_bar' => esc_html__( 'Document', 'mb86' ),
'add_new' => esc_html__( 'Add new', 'mb86' ),
'add_new_item' => esc_html__( 'Add new Document', 'mb86' ),
'new_item' => esc_html__( 'New Document', 'mb86' ),
'edit_item' => esc_html__( 'Edit Document', 'mb86' ),
'view_item' => esc_html__( 'View Document', 'mb86' ),
'update_item' => esc_html__( 'Update Document', 'mb86' ),
'all_items' => esc_html__( 'All Documents', 'mb86' ),
'search_items' => esc_html__( 'Search Documents', 'mb86' ),
'parent_item_colon' => esc_html__( 'Parent Document', 'mb86' ),
'not_found' => esc_html__( 'No Documents found', 'mb86' ),
'not_found_in_trash' => esc_html__( 'No Documents found in Trash', 'mb86' ),
'name' => esc_html__( 'Documents', 'mb86' ),
'singular_name' => esc_html__( 'Document', 'mb86' ),
),
'public' => true,
'description' => 'Handbooks, manuals, and other documents.',
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-book-alt',
'capability_type' => 'post',
'hierarchical' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite_no_front' => false,
'supports' => array(
'title',
'thumbnail',
),
'rewrite' => true,
);
register_post_type( 'document', $args );
}
add_action( 'init', 'register_document' );
Since most topics addressing this issue focus updating permalinks (which I've repeatedly tried), I'm not really sure how to fix this. Any ideas?