Title: Get custom post type?
Last modified: August 30, 2016

---

# Get custom post type?

 *  [WP CMS Ninja](https://wordpress.org/support/users/billiardgreg/)
 * (@billiardgreg)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/get-custom-post-type/)
 * So I am currently trying to get the current post type in a class. Unfortunately
   it seems like due to me trying to get it in the construct it is not returning
   the correct value. I attempted the following but it is not doing it correctly.
   Have been unable to find how to do it in the construct.
 *     ```
       $post_type = get_post_type($post->ID);
       if ($post_type == 'some_cpt') {
       //do something
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  [Ravikumar Patel](https://wordpress.org/support/users/ravipatel/)
 * (@ravipatel)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/get-custom-post-type/#post-6394509)
 * This code [@return](https://wordpress.org/support/users/return/) string|false
   Post type on success, false on failure.
 * [Please see process code hear.](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/post.php#L0)

Viewing 1 replies (of 1 total)

The topic ‘Get custom post type?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Ravikumar Patel](https://wordpress.org/support/users/ravipatel/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/get-custom-post-type/#post-6394509)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
