Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Created August 27, 2015 21:33
Show Gist options
  • Save jazzsequence/c640d77afbdd409e7e2f to your computer and use it in GitHub Desktop.
Save jazzsequence/c640d77afbdd409e7e2f to your computer and use it in GitHub Desktop.
function that will return an array of post types for a cmb2 options array
<?php
/**
* Get an array of post types for the options page multicheck array
* @uses get_post_types
* @return array An array of public post types
*/
public function get_post_types() {
/**
* Filter that allows you to modify the post types array
*/
$post_types = apply_filters( 'myprefix_post_types', get_post_types( array( 'public' => true ), 'objects' ) );
foreach ( $post_types as $post_type ) {
$types[$post_type->name] = $post_type->labels->name;
}
return $types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment