How can i check for post_types in the templates?
1. post
2. page
3. event post_types?
cheers
How can i check for post_types in the templates?
1. post
2. page
3. event post_types?
cheers
To check if it's a page:
To check if it's a single post:
To check for a custom post type, it can depend on when and where you want to check. For example, if your in the loop, you could do something like this:
if ( 'my_post_type' == get_post_type() ) {
/* Stuffs */
} else {
/* Other stuffs */
}
Function Reference/get post type
You can also make specific single and archive template files that target a specific post type. You check out this page for more information on that:
You must log in to post.