Skip to content

Instantly share code, notes, and snippets.

@mdjwel
Created September 8, 2018 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdjwel/f4c9f03990cdafeeb5e3baaaf8a670ba to your computer and use it in GitHub Desktop.
Save mdjwel/f4c9f03990cdafeeb5e3baaaf8a670ba to your computer and use it in GitHub Desktop.
Get post types array with name => singular name
<?php
// Get post types
function skima_post_types() {
$post_types = get_post_types([], 'objects');
$posts = array();
foreach ($post_types as $post_type) {
$posts[$post_type->name] = $post_type->labels->singular_name;
}
return $posts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment