get_post_types_by_support

Retrieves a list of post type names that support a specific feature.

Description

(array) get_post_types_by_support( (array|string) $feature, (string) $operator = 'and' ); 

Returns (array)

A list of post type names.

Parameters (2)

0. $feature (array|string)
Single feature or an array of features the post types should support.
1. $operator — Optional. (string) => 'and'
The logical operation to perform. or means only one element from the array needs to match; and means all elements must match; not. means no elements may match. Default and.

Usage

  1. if ( !function_exists( 'get_post_types_by_support' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // Single feature or an array of features the post types should support. 
  5. $feature = null; 
  6. $operator = 'and'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_post_types_by_support($feature, $operator); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function get_post_types_by_support( $feature, $operator = 'and' ) { 
  2. global $_wp_post_type_features; 
  3.  
  4. $features = array_fill_keys( (array) $feature, true ); 
  5.  
  6. return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );