WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type (2 posts)

  1. aled2305
    Member
    Posted 10 months ago #

    Hello, Sorry for posting so much yesterday, I am trying to create a custom post type... Now adding

    add_action( 'init', 'register_cpt_tutorial' );
    
    function register_cpt_tutorial() {
    
        $labels = array(
            'name' => _x( 'Tutorials', 'tutorial' ),
            'singular_name' => _x( 'Tutorial', 'tutorial' ),
            'add_new' => _x( 'Add New', 'tutorial' ),
            'add_new_item' => _x( 'Add New Tutorial', 'tutorial' ),
            'edit_item' => _x( 'Edit Tutorial', 'tutorial' ),
            'new_item' => _x( 'New Tutorial', 'tutorial' ),
            'view_item' => _x( 'View Tutorial', 'tutorial' ),
            'search_items' => _x( 'Search Tutorials', 'tutorial' ),
            'not_found' => _x( 'No tutorials found', 'tutorial' ),
            'not_found_in_trash' => _x( 'No tutorials found in Trash', 'tutorial' ),
            'parent_item_colon' => _x( 'Parent Tutorial:', 'tutorial' ),
            'menu_name' => _x( 'Tutorials', 'tutorial' ),
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'description' => 'Tutorials description will be here',
            'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
            'taxonomies' => array( 'category' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 20,
    
            '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( 'tutorial', $args );

    To my functions.php file has made a new post type, but I want this post type to use a new file E.G tutorial_post.php instead of post.php and I would like the custom post type to have it's own category's not use the same on as the other posts. If this is quite simple to explain can someone please help, if not I can't seem to find one, but is there a idiots guide (step by step) on how to do this.

    Thanks in advance

    Aled

  2. vtxyzzy
    Member
    Posted 9 months ago #

    The Custom Post Type UI plugin can make creating CPTs and taxonomies much easier. You can create a taxonomy and assign it to your CPT.

Reply

You must log in to post.

About this Topic