Last active
October 28, 2017 15:05
-
-
Save ann71727/158bf5fdab76a791da9ebe3e986474db to your computer and use it in GitHub Desktop.
List All Post Type Names
This file contains 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 | |
/* | |
* List All Post Type Names | |
* https://v123.tw | |
*/ | |
function v123_get_all_post_type_names(){ | |
global $wp_post_types; | |
$posttypes = array_keys( $wp_post_types ); | |
// exclude_post_type 排除的 Post Type name | |
$exclude_post_type = array("attachment","nav_menu_item","customize_changeset","revision"); | |
foreach ( $posttypes as $posttype ): | |
if ( in_array($posttype, $exclude_post_type) ) continue; | |
$posttype_names[ $posttype ] = $posttype; | |
endforeach; | |
print_r($posttype_names); | |
} | |
add_action('init','v123_get_all_post_type_names'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment