Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hawkidoki/0c925026fd55c7ad47bbb7818dd46fcb to your computer and use it in GitHub Desktop.
Save hawkidoki/0c925026fd55c7ad47bbb7818dd46fcb to your computer and use it in GitHub Desktop.
<?php
// Register Post Type
add_action('init', 'hwk_post_type_exemple', 0);
function hwk_post_type_exemple(){
register_post_type('exemple', array(
'hierarchical' => false, // true | false. See 'post_row_actions' & 'page_row_actions' filters
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'rewrite' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'has_archive' => 'exemples'
));
}
// Remove Single Rewrite Rules
// '{permastruture}_rewrite_rules' filter
add_filter('exemple_rewrite_rules', '__return_empty_array');
// Remove Post Type List Action 'View'
add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2); // if post_type is hierarchical
add_filter('post_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2); // if post_type is not hierarchical
function hwk_post_type_exemple_row_actions($actions, $post){
if(!isset($post->post_type) || $post->post_type != 'exemple')
return $actions;
unset($actions['view']);
return $actions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment