Skip to content

Instantly share code, notes, and snippets.

@Lukas238
Created July 23, 2015 15:28
Show Gist options
  • Save Lukas238/93a1348c489245f154fc to your computer and use it in GitHub Desktop.
Save Lukas238/93a1348c489245f154fc to your computer and use it in GitHub Desktop.
List all existing custom post types in Wordpress.
<?php
/**
* Template Name: Custom Post Types List
*/
get_header();
$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;
}
echo "<pre>";
print_r($posttypes_array);
echo "</pre>";
get_footer();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment