WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to have custom post type that have only title and archive page, but no detail page.

Here is what custom post type code:

add_action( 'init', 'register_cpt_trivia' );

function register_cpt_trivia() {

    $labels = array( 
        'name' => _x( 'Trivia', 'trivia' ),
        'singular_name' => _x( 'Trivia', 'trivia' ),
        'add_new' => _x( 'Add New', 'trivia' ),
        'add_new_item' => _x( 'Add New Trivia', 'trivia' ),
        'edit_item' => _x( 'Edit Trivia', 'trivia' ),
        'new_item' => _x( 'New Trivia', 'trivia' ),
        'view_item' => _x( 'View Trivia', 'trivia' ),
        'search_items' => _x( 'Search Trivia', 'trivia' ),
        'not_found' => _x( 'No trivia found', 'trivia' ),
        'not_found_in_trash' => _x( 'No trivia found in Trash', 'trivia' ),
        'parent_item_colon' => _x( 'Parent Trivia:', 'trivia' ),
        'menu_name' => _x( 'Trivia', 'trivia' ),

    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'Few line text with no detail pages.',
        'supports' => array( 'title' ),

        'public' => false,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 20,

        'show_in_nav_menus' => false,
        'publicly_queryable' => true,
        'exclude_from_search' => true,
        'has_archive' => true,

        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'

    register_post_type( 'trivia', $args );
share|improve this question
Do you mean that you don't want any 'single' listing for this type? You'd only have the index list and nothing more? – s_ha_dum Nov 11 '12 at 17:11
Yes, exactly. I want only index page but no singe page. – Krunal Nov 12 '12 at 4:03
up vote 1 down vote accepted

You can't just disable single pages, you can however make it appear as if they do not exist. I suggest

1) ensure that there are no links on the site pointing to the single page

2) Create a file "single-trivia.php" in your theme with the content as <?php include '404.php';?>

3) use template_redirect or template_include hook to change the template to 404 if it's a single trivia page

4) use post_row_actions hook to remove the view link from admin panel

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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