Check for custom post types – WordPress

If you work with WordPress themes and Custom Post Types you will love the snippet below.

This is a conditional check for custom post types within The Loop:

If you want to use the snippet outside the loop you just need to pass the post ID:

Learn more about the get_post_type function.

No comments yet, leave yours!

Leave a Reply

Add <code> Some Code </code> by using this tags.