Skip to content

Instantly share code, notes, and snippets.

@clifgriffin clifgriffin/custom-post-type.php Secret
Last active Aug 29, 2015

Embed
What would you like to do?
Gravity Forms Download Lead Capture: Custom Post Type for Downloads
<?php // Don't include opening PHP tag
add_action( 'init', 'register_cpt_download' );
function register_cpt_download() {
$labels = array(
'name' => _x( 'Downloads', 'download' ),
'singular_name' => _x( 'Download', 'download' ),
'add_new' => _x( 'Add New', 'download' ),
'add_new_item' => _x( 'Add New Download', 'download' ),
'edit_item' => _x( 'Edit Download', 'download' ),
'new_item' => _x( 'New Download', 'download' ),
'view_item' => _x( 'View Download', 'download' ),
'search_items' => _x( 'Search Downloads', 'download' ),
'not_found' => _x( 'No downloads found', 'download' ),
'not_found_in_trash' => _x( 'No downloads found in Trash', 'download' ),
'parent_item_colon' => _x( 'Parent Download:', 'download' ),
'menu_name' => _x( 'Downloads', 'download' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Private downloads.',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-download',
'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'download', 'with_front' => false, 'feed' => false, 'pages' => false),
'capability_type' => 'post'
);
register_post_type( 'download', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.