Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#35810 closed enhancement (wontfix)

New function: `is_post_type`

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

I think that helpful will be function:

<?php
if(is_post_type('CPT')) echo 'true'; else {echo 'false';}

Attachments (1)

35810.patch (765 bytes) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @swissspidy
9 years ago

Why is is_post_type( 'abc' ) better than 'abc' === get_post_type()?

I don't really see a benefit here. People could even confuse it with is_post_type_archive()

#2 @ramiy
9 years ago

If you are trying the check whether the query is for an archive page of a given post type, use the is_post_type_archive() function.

#3 @swissspidy
8 years ago

  • Keywords close added

#4 @SergeyBiryukov
8 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As noted above, this is not much an improvement over get_post_type().

Note: See TracTickets for help on using tickets.