I made a custom post type named rt_test in a WordPress plugin as follow:

register_post_type( 'rt_test',
            '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
  • 1
    Did you flush the permalinks structure by saving permalink again ?
    – Sumit
    Commented Feb 26, 2016 at 4:23
  • The trick works ! But how come ? I didn't change Permalink structure since I build the plugin & theme.
    – Raptor
    Commented Feb 26, 2016 at 4:26
  • 1
    because the new rewrite rules relating to the CPT are not created and written to the database until you flush_rewrite_rules which saving permalinks also triggers.
    – majick
    Commented Feb 26, 2016 at 5:53
  • Can you post it as answer? I want to accept it, thanks.
    – Raptor
    Commented Feb 26, 2016 at 6:05

1 Answer 1


Go to Appearance » Menus and add a custom link to your menu. This custom link is the link to your custom post type. If you are using SEO friendly permalinks then your CPT’s URL will most likely be something like this:


If you are not using SEO friendly permalinks, then your custom post type URL will be something like this:


Make sure that your permalink structure matches up to the URL you are entering to try to get to the custom post page and check to make sure that your .htaccess file is writable, if not, you will have to insert the rewrite rules generated by wordpess on your own.

  • No, this is not for listing, it's for single post for the Custom Post Type.
    – Raptor
    Commented Feb 26, 2016 at 4:16
  • The above trick is what I was trying to get you to do. Glad it worked for you.
    – JWLKR
    Commented Feb 26, 2016 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.