WordPress.org

Forums

Custom Post Type Not Recognizing single-custompostname.php (1 post)

  1. Peter
    Member
    Posted 1 year ago #

    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 );
        }

Topic Closed

This topic has been closed to new replies.

About this Topic