Created
August 27, 2015 21:33
-
-
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
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 | |
/** | |
* 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