Skip to content

Instantly share code, notes, and snippets.

@shaddam
Created November 18, 2019 03:46
Show Gist options
  • Select an option

  • Save shaddam/748d3aa63c90b3a84cba64de210db33c to your computer and use it in GitHub Desktop.

Select an option

Save shaddam/748d3aa63c90b3a84cba64de210db33c to your computer and use it in GitHub Desktop.
Get Post Type List in WP for elementor addons
/*
* 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