Skip to content

Instantly share code, notes, and snippets.

@gyrus
Created July 21, 2012 19:27
Show Gist options
  • Save gyrus/3156901 to your computer and use it in GitHub Desktop.
Save gyrus/3156901 to your computer and use it in GitHub Desktop.
Put WordPress custom post types in a global variable
<?php
/**
* Store public custom post types in global variable
*/
add_action( 'init', 'pilau_custom_post_types_var', 1 );
function pilau_custom_post_types_var() {
global $pilau_custom_post_types;
$pilau_custom_post_types = get_post_types( array(
'public' => true,
'_builtin' => false
), 'objects', 'and' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment