2

When you register a post type you can pass an array of arguments that it "supports." (For example, "page-attributes," "author," "editor," etc.)

I see that get_post_types has some args you can filter by, but how can I filter those that "support" specific features such as "page-attributes" or "author"? I realize I could run a loop to filter after the fact, but can this be done without an extra step?

Thanks.

2

Yes, this can be done. Here's how:

get_post_types( array('supports' => array('page-attributes')), 'names', 'OR');

This Trac ticket provides some explanation as to why that last parameter—the 'OR'—is necessary: http://core.trac.wordpress.org/ticket/17620

  • Thanks for the reply. I'm running into the same thing as GaryJ (core.trac.wordpress.org/ticket/17620#comment:2). It's appears to be returning all posts—those that do and don't provide support. I'm just going to stick with subsequent loop using post_type_supports() for now. – robertwbradford Dec 9 '11 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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