Title: Single-posttype.php
Last modified: August 21, 2016

---

# Single-posttype.php

 *  [girll](https://wordpress.org/support/users/girll/)
 * (@girll)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/single-posttypephp/)
 * Hi all. I have a question, please help me.
 * I have posts that have post_type products. I know I must add new single-products.
   php. But I don know how? What I should write in that file. ANd how will make 
   that file work?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  [morollian](https://wordpress.org/support/users/morollian/)
 * (@morollian)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/single-posttypephp/#post-3996374)
 * hi girll,
 * First of all add this to your functions.php file:
 *     ```
       function my_custom_init() {
            $labels = array(
               'name' => 'your_post_type_name',
               'singular_name' => 'your_post_type_name(in singular)',
               'add_new' => 'New your_post_type_name',
               'add_new_item' => 'New your_post_type_name',
               'edit_item' => 'Edit your_post_type_name',
               'new_item' => 'New your_post_type_name',
               'all_items' => 'All your_post_type_name',
               'view_item' => 'View your_post_type_name',
               'search_items' => 'Search your_post_type_name',
               'not_found' =>  'No your_post_type_name where found',
               'not_found_in_trash' => 'No your_post_type_name where found in the trash',
               'parent_item_colon' => '',
               'menu_name' => 'No your_post_type_name where found'
             );
   
            $args= array(
               'labels' => $labels,
               'public' => true,
               'publicly_queryable' => true,
               'show_ui' => true,
               'show_in_menu' => true,
               'query_var' => true,
               'rewrite' => array( 'slug' => 'your_post_type_name' ),
               'capability_type' => 'post',
               'has_archive' => true,
               'hierarchical' => false,
               'menu_position' => 5, //this is the position on your dashboard menu, 5 means under the Post item.
               'taxonomies' => array ('post_tag'),
               'supports' => array( 'title', 'editor', 'author', 'thumbnail' ) //this ads which features does your post type suports
             );
   
           register_post_type( 'your_post_type_name', $args );
           }
   
           add_action( 'init', 'my_custom_init' ); //this is an action hook, it says to WP that this function must be executed at 'init'
       ```
   
 * This will make your post type apear on your admin dashboard.
 * Then you create a file named single-{your_post_type_name}.php in your template
   folder.
    ie: if your post type name is Book the file should be named single-book.
   php.
 * And that would be all. Hope it works for you!
 * You should also hava a look to the codex, it’s usually really helfull: [post types](http://codex.wordpress.org/Post_Types)

Viewing 1 replies (of 1 total)

The topic ‘Single-posttype.php’ is closed to new replies.

## Tags

 * [post_type](https://wordpress.org/support/topic-tag/post_type/)
 * [single.php](https://wordpress.org/support/topic-tag/single-php/)

 * 1 reply
 * 2 participants
 * Last reply from: [morollian](https://wordpress.org/support/users/morollian/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/single-posttypephp/#post-3996374)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
