Skip to content

Instantly share code, notes, and snippets.

@jeffikus
Created March 4, 2014 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffikus/9342341 to your computer and use it in GitHub Desktop.
Save jeffikus/9342341 to your computer and use it in GitHub Desktop.
Modify Features Post Type to only allow publicly queryable posts, but disable archive and single feature posts
add_action( 'init', 'modify_existing_post_type', 50 );
/**
* Modify Existing post type.
*
* @access public
* @param string $token
* @param string 'Features'
* @param string 'Features'
* @param array $supports
* @return void
*/
function modify_existing_post_type () {
$labels = array(
'name' => _x( 'Features', 'post type general name', 'woothemes-features' ),
'singular_name' => _x( 'Feature', 'post type singular name', 'woothemes-features' ),
'add_new' => _x( 'Add New', 'feature', 'woothemes-features' ),
'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-features' ), __( 'Feature', 'woothemes-features' ) ),
'edit_item' => sprintf( __( 'Edit %s', 'woothemes-features' ), __( 'Feature', 'woothemes-features' ) ),
'new_item' => sprintf( __( 'New %s', 'woothemes-features' ), __( 'Feature', 'woothemes-features' ) ),
'all_items' => sprintf( __( 'All %s', 'woothemes-features' ), __( 'Features', 'woothemes-features' ) ),
'view_item' => sprintf( __( 'View %s', 'woothemes-features' ), __( 'Feature', 'woothemes-features' ) ),
'search_items' => sprintf( __( 'Search %a', 'woothemes-features' ), __( 'Features', 'woothemes-features' ) ),
'not_found' => sprintf( __( 'No %s Found', 'woothemes-features' ), __( 'Features', 'woothemes-features' ) ),
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'woothemes-features' ), __( 'Features', 'woothemes-features' ) ),
'parent_item_colon' => '',
'menu_name' => __( 'Features', 'woothemes-features' )
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ),
'menu_position' => 5,
'menu_icon' => ''
);
register_post_type( 'feature', $args );
} // End register_post_type()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment