WordPress hwk Codes Supprimer les Post Types par Défaut de WordPress (Post & Page)

Supprimer les Post Types par Défaut de WordPress (Post & Page)

17 April 2018
<?php
add_action('init', 'hwk_deregister_builtin_post_type');
function hwk_deregister_builtin_post_type(){
global $wp_post_types;
$unregister = array(
'post',
'page',
);
foreach($unregister as $post_type){
if(!post_type_exists($post_type))
continue;
$post_type_object = get_post_type_object($post_type);
$post_type_object->remove_supports();
$post_type_object->remove_rewrite_rules();
$post_type_object->unregister_meta_boxes();
$post_type_object->remove_hooks();
$post_type_object->unregister_taxonomies();
unset($wp_post_types[$post_type]);
do_action('unregistered_post_type', $post_type);
$wp_post_types[$post_type] = new stdClass();
$wp_post_types[$post_type]->show_in_menu = false;
$wp_post_types[$post_type]->publicly_queryable = false;
$wp_post_types[$post_type]->_builtin = false;
$wp_post_types[$post_type]->name = false;
}
}


Konrad Chmielewski

Evangeliste WordPress & Full Stack Developer depuis 10 années.