WordPress.org

Support

Support » How-To and Troubleshooting » Array for 'all' custom post types?

Array for 'all' custom post types?

  • When creating a query array for custom post types, is there a way of including all types without having to list them all as they are created?

    for example

    'post_type' => array ('post', 'blog-item', 'company-spotlight', 'ebook', 'podcast', 'photo-gallery', 'presentation-slide', 'video', 'white-paper'),

    would look something like:

    'post_type' => array ('post', 'ALL_CUSTOM_POST_TYPES'),

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try this.

    $post_types = get_post_types( '','names' );
    ...
    'post_type' => $post_types,

    Thanks wpcanyon, so there isn’t an array for all custom post types?

    Ahh sorry, i was wrong. Just remembered there’s this…

    'post_type' => 'any',

    Awesome, thanks wpcanyon!

    I also want to register the following function for adding tags metaboxes to ‘any’ post type but it doesn’t work? Any ideas?

    function demo_add_default_boxes() {
    register_taxonomy_for_object_type('post_tag', 'any');
    }

    I don’t think there’s a value for all. And that second parameter (for the post type) is for a single post type.

    Why don’t you attach the post_tag taxonomy directly in the register_post_type

    register_post_type( 'post_type_name', array(
        'taxonomies' => array( 'post_tag' ),
        'blah blah' => 'blah blah'
        ...
    ));
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Array for 'all' custom post types?’ is closed to new replies.
Skip to toolbar