Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We know you can do if ( is_singular( 'my-cpt' ) ) to test for a specific custom post type, but what about doing one thing if the post is a built-in post type, and another if it is not?

Is it enough to just test against if ( is_singular() && ! is_singular( 'post' ) )? Or are there some implications or subtleties that are escaping me at the moment?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I don't know of a conditional tag, but here's how you would list the built-in types:

echo implode(',', get_post_types( array('_builtin' => true ) ) );

Output:

post,page,attachment,revision,nav_menu_item

Maybe better:

// 1 result if it exists and is builtin, 0 otherwise
get_post_types( array('_builtin' => true, 'name' => $post_type ) );
share|improve this answer
    
That's a great angle! –  Tom Auger Oct 3 '11 at 16:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.