I made a custom post type named rt_test
in a WordPress plugin as follow:
register_post_type( 'rt_test',
array(
'labels' => array(
'name' => __( 'Tests' ),
'singular_name' => __( 'Test' ),
'add_new' => __('New Test'),
'add_new_item' => __('Add New Test'),
'edit_item' => __('Edit Test'),
'view_item' => __('View Test'),
'search_items' => __('Search Test'),
'not_found' => __('No Test found'),
'not_found_in_trash' => __('No Test found in Trash'),
),
'public' => true,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail' ),
'has_archive' => true,
)
);
And its data can be loaded via WP_Query()
in index.php
page of my theme. However, when I try to access the custom post type page (e.g. http://www.example.com/rt_test/test1/ ), it directs to WordPress's Page Not Found page.
From the Template Hierarchy documentation, I know that I should make a single-rt_test.php
file in theme's folder to allow the theme to know the content of this file should be used to load the post "test1".
However, after uploading the file to theme folder in parallel with index.php
, the link ( http://www.example.com/rt_test/test1/ ) still redirects to Not Found page.
What did I miss?
FYI, the theme folder only contains:
- index.php
- single-rt_test.php
- style.css
flush_rewrite_rules
which saving permalinks also triggers.