Title: Current Post Type Info
Last modified: August 20, 2016

---

# Current Post Type Info

 *  [Elliot Toman](https://wordpress.org/support/users/asubtleweb/)
 * (@asubtleweb)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/)
 * I’m a PHP dullard, but I’ll phrase this as best I can: Is there a way to retrieve
   information about the currently active post type in a template? For example, 
   if I have several custom post types, and I want to add a wp_query in my index.
   php template that lists only the posts in the currently active post type.
 * I experimented with get_post_type_labels and get_post_type_object, but wasn’t
   able to accomplish anything except generating errors. ;p

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431889)
 * This is the template hierarchy for displaying custom post type posts: [http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display](http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display)
 * Try it with [get_post_type()](http://codex.wordpress.org/Function_Reference/get_post_type)
 *     ```
       $posttype = get_post_type();
       // or
       $posttype = get_post_type($post);
       // or
       $posttype = get_post_type($post->ID);
       ```
   
 *  Thread Starter [Elliot Toman](https://wordpress.org/support/users/asubtleweb/)
 * (@asubtleweb)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431906)
 * Wow, that was easy. Thank you!
 * Is there any way to retrieve the labels for the post type, such as the singular
   or plural names?
 *  Thread Starter [Elliot Toman](https://wordpress.org/support/users/asubtleweb/)
 * (@asubtleweb)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431910)
 * I figured it out!
 *     ```
       <?php $posttype = get_post_type(); ?>
       <?php $obj = get_post_type_object( $posttype ); ?>
       <?php print $obj->labels->name; ?>
       ```
   
 * Thanks again for your help. 🙂
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431914)
 * try it with: [http://codex.wordpress.org/Function_Reference/get_post_type_object](http://codex.wordpress.org/Function_Reference/get_post_type_object)
 *     ```
       $posttype = get_post_type();
       $obj = get_post_type_object($posttype);
       print $obj->labels->singular_name;
       ```
   
 * [edit] oops, too late.
 *  Thread Starter [Elliot Toman](https://wordpress.org/support/users/asubtleweb/)
 * (@asubtleweb)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431915)
 * I can’t tell you how gratifying it is that we settled on the same solution.

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

The topic ‘Current Post Type Info’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Elliot Toman](https://wordpress.org/support/users/asubtleweb/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/current-post-type-info/#post-2431915)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
