Title: Post Type Name in header
Last modified: September 1, 2016

---

# Post Type Name in header

 *  [candell](https://wordpress.org/support/users/candell/)
 * (@candell)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/post-type-name-in-header/)
 * I’m having a mental block.
 * I want to echo the post type name in my header.php file so that I can style it
   specific to the post type.
 * Can anyone help?
 * Thanks

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

 *  [MyThemeShop](https://wordpress.org/support/users/mythemeshop/)
 * (@mythemeshop)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/post-type-name-in-header/#post-7666230)
 * Hi,
    I’m not quite sure what you’re looking for. If you want to style the single
   post page for the custom post type, you can use the `single-xxx` (where `xxx`
   is the post type name) body class added by WP automatically. If you actually 
   want to print the post type name, you can use the `get_post_type()` function:
   [https://developer.wordpress.org/reference/functions/get_post_type/](https://developer.wordpress.org/reference/functions/get_post_type/)
   To add specific code in the header.php for the post type you can do something
   like this:
 *     ```
       if ( get_post_type() == 'your_custom_posttype' ) {
         // Do stuff
       }
       ```
   
 * Hope that helps.
 *  Thread Starter [candell](https://wordpress.org/support/users/candell/)
 * (@candell)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/post-type-name-in-header/#post-7666268)
 * Thanks for the help, I had typed get_pot_type hence the issue. Sorry, the curse
   of lack of sleep strikes!
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/post-type-name-in-header/#post-7666272)
 *     ```
       global $wp_query;
       if ( $wp_query->get( 'post_type' ) === 'POSTTYPE' ) {
   
       }
       ```
   
 * will work on the post type archive and single posts of that type.
 * If you have a taxonomy archive in the mix you’ll need to check that separately:
 *     ```
       global $wp_query;
       if ( $wp_query->get( 'post_type' ) === 'POSTTYPE' || $wp_query->get( 'taxonomy' ) === 'TAXONOMY' ) {
   
       }
       ```
   
 * Edit: Sorry, I misread that as you saying you’d tried get_post_type and it didn’t
   work. Oh well, there’s another solution.

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

The topic ‘Post Type Name in header’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/post-type-name-in-header/#post-7666272)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
