Title: problem with post_type on custom post type
Last modified: August 19, 2016

---

# problem with post_type on custom post type

 *  Resolved [niceandripe](https://wordpress.org/support/users/niceandripe/)
 * (@niceandripe)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/problem-with-post_type-on-custom-post-type/)
 * I’ve created two custom post types pretty much the same
 *     ```
       add_action('init', 'classifieds');
   
       function classifieds() {
       $args = array(
       'label' => __('Classifieds'),
       'singular_label' => __('Listing'),
       'public' => true,
       'show_ui' => true,
       'capability_type' => 'post',
       'hierarchical' => false,
       'rewrite' => true,
       'supports' => array('title', 'editor', 'thumbnail')
       );
   
       register_taxonomy( 'classifieds-category', 'classifieds',
       array(
       'hierarchical' => false,
       'label' => __('Categories'),
       'query_var' => 'classifieds-category',
       'rewrite' => array('slug' => 'classifieds-category' )
       )
       );
   
       register_post_type( 'classifieds' , $args );
       }
       ```
   
 * and also
 *     ```
       add_action('init', 'directory');
   
       function directory() {
       $args = array(
       'label' => __('Directory'),
       'singular_label' => __('Listing'),
       'public' => true,
       'show_ui' => true,
       'capability_type' => 'post',
       'hierarchical' => false,
       'rewrite' => true,
       'supports' => array('title', 'editor', 'thumbnail')
       );
   
       register_taxonomy( 'directory-category', 'directory',
       array(
       'hierarchical' => false,
       'label' => __('Categories'),
       'query_var' => 'directory-category',
       'rewrite' => array('slug' => 'directory-category' )
       )
       );
   
       register_post_type( 'directory' , $args );
       }
       ```
   
 * however if I use
    `<?php echo $post_type ?>` they both show the same – “directory”
   and i can’t seem to get “classifieds” for the classifieds posts?!
 * ??

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/problem-with-post_type-on-custom-post-type/#post-1575871)
 * If you are talking about the post_type for a given post and you are in a “standard”
   [loop](http://codex.wordpress.org/The_Loop), then $post->post_type would hold
   that value.
 *  Thread Starter [niceandripe](https://wordpress.org/support/users/niceandripe/)
 * (@niceandripe)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/problem-with-post_type-on-custom-post-type/#post-1575919)
 * perfect, thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘problem with post_type on custom post type’ is closed to new replies.

## Tags

 * [post_types](https://wordpress.org/support/topic-tag/post_types/)

 * 2 replies
 * 2 participants
 * Last reply from: [niceandripe](https://wordpress.org/support/users/niceandripe/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/problem-with-post_type-on-custom-post-type/#post-1575919)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
