J.me

Checking the current post type with is_singular function

The WordPress 3 introduce a new feature that let us easily make our own custom post type. This is really a cool feature that give more possibility to customize the WordPress powered website. However, I find that the documentation is not complete yet.

In the recent problem I got, it requires me to check the current post type, something like is_single for post and is_page for page. Luckily enough, the is_singular is now changed to accept a parameter, and that is post type. 🙂

In current codex page, it still not updated. However, now we can use this to check whether we are on our post type page or not.

if ( is_singular(“my-post-type”) )
// whatever you want to do here

Great!

No comment yet

Leave a comment