-
-
Save Lukas238/93a1348c489245f154fc to your computer and use it in GitHub Desktop.
List all existing custom post types in Wordpress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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