Created
October 8, 2017 22:31
-
-
Save damiencarbery/bb9333a9801d553b2b2815c9a37e7e79 to your computer and use it in GitHub Desktop.
Hide Specified Custom Post Types - with a little gotcha!!
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 | |
// Based on: http://markwilkinson.me/2014/09/altering-registered-post-type-args/ | |
// Hide some of the k-boom CPTs as they will not be used. | |
function ce_hide_some_cpts( $post_type, $args ) | |
{ | |
/* Only hide the post types listed in the array. */ | |
if (!in_array($post_type, array('audio', 'event', 'portfolio', 'video'))) { | |
return; | |
} | |
// Skip 'Events Manager' plugin (it has 'description' set while 'Events' CPT does not). | |
if ('Display events on your blog.' == $args->description) { | |
return; | |
} | |
global $wp_post_types; | |
/* Hide CPT. */ | |
$args->show_ui = false; | |
/* modify post type object to implement the changes */ | |
$wp_post_types[ $post_type ] = $args; | |
} | |
add_action( 'registered_post_type', 'ce_hide_some_cpts', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment