Created
November 18, 2019 03:46
-
-
Save shaddam/748d3aa63c90b3a84cba64de210db33c to your computer and use it in GitHub Desktop.
Get Post Type List in WP for elementor addons
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
| /* | |
| * Get Post Type | |
| * return array | |
| */ | |
| function themename_get_post_types( $args = [] ) { | |
| $post_type_args = [ | |
| 'show_in_nav_menus' => true, | |
| ]; | |
| if ( ! empty( $args['post_type'] ) ) { | |
| $post_type_args['name'] = $args['post_type']; | |
| } | |
| $_post_types = get_post_types( $post_type_args , 'objects' ); | |
| $post_types = []; | |
| foreach ( $_post_types as $post_type => $object ) { | |
| $post_types[ $post_type ] = $object->label; | |
| } | |
| return $post_types; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment