Last active
September 12, 2019 23:28
-
-
Save hwkdev/0c925026fd55c7ad47bbb7818dd46fcb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// 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