Skip to content

Instantly share code, notes, and snippets.

@interactiveRob
Created November 8, 2018 18:21
Show Gist options
  • Select an option

  • Save interactiveRob/f86e53a11da619ea73ce48ac42b261f8 to your computer and use it in GitHub Desktop.

Select an option

Save interactiveRob/f86e53a11da619ea73ce48ac42b261f8 to your computer and use it in GitHub Desktop.
Show a list of wordpress registered custom post types
function show_registered_post_types(){
$args=array(
'public' => true,
'exclude_from_search' => false,
'_builtin' => false
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types($args,$output,$operator);
$posttypes_array = array();
foreach ($post_types as $post_type ) {
$posttypes_array[] = $post_type;
}
var_dump($posttypes_array);
}
add_action( 'wp_head', 'show_registered_post_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment