• Peter

    (@peterbatchelder)


    Stuck. Created Custom Post Type “tournaments” with Advanced Custom Fields. All works well, but new CPT still uses default single.php even though I created a singe-tournaments.php template. Help much appreciated.

    add_action( 'init', 'register_cpt_tournament' );
        function register_cpt_tournament() {
        $labels = array(
        'name' => _x( 'tournaments', 'tournament' ),
        'singular_name' => _x( 'tournament', 'tournament' ),
        'add_new' => _x( 'Add New', 'tournament' ),
        'add_new_item' => _x( 'Add New tournament', 'tournament' ),
        'edit_item' => _x( 'Edit tournament', 'tournament' ),
        'new_item' => _x( 'New tournament', 'tournament' ),
        'view_item' => _x( 'View tournament', 'tournament' ),
        'search_items' => _x( 'Search tournaments', 'tournament' ),
        'not_found' => _x( 'No tournaments found', 'tournament' ),
        'not_found_in_trash' => _x( 'No tournaments found in Trash', 'tournament' ),
        'parent_item_colon' => _x( 'Parent tournament:', 'tournament' ),
        'menu_name' => _x( 'tournaments', 'tournament' ),
        );
        $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
        'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
        );
        register_post_type( 'tournament', $args );
        }
  • The topic ‘Custom Post Type Not Recognizing single-custompostname.php’ is closed to new replies.