Create a Custom Post Type Download

Custom Post Type Download

Nowadays when WordPress become most used CMS, users are searching for various improvements for their sites. WordPress have ability to add custom post types and taxonomies easily with some snippet code in your functions.php file, or even easier trough the various plugins witch brings you this and similar options like custom taxonomies, custom meta boxes, fields etc. All those snippets/add-ons can quickly turn your WordPress site into well-featured CMS.

One of the easiest ways to add custom post type is trough the free WordPress plugin Custom Post Type Maker. Personally I preffer adding them with snippet code so I brings you simple snippet code that is ready to paste into functions.php file.

Custom Post Type Snippet

* Snippet Name: Create a Custom Post Type "Download"
* Snippet URL:

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’ => true,
‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘trackbacks’, ‘custom-fields’, ‘comments’, ‘revisions’, ‘page-attributes’ ),
‘taxonomies’ => array( ‘category’, ‘post_tag’ ),
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_position’ => 5,
‘menu_icon’ => ”,
‘show_in_nav_menus’ => true,
‘publicly_queryable’ => true,
‘exclude_from_search’ => false,
‘has_archive’ => true,
‘query_var’ => true,
‘can_export’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’
register_post_type( ‘download’, $args );

The known issue when the custom post types are created trough the snippet is that WordPress does not automatically take your custom post types and add them to the archive pages for existing taxonomies like categories or post_tags. Because of that we have prepared you another snippet for adding custom post types to archives page with snippet too.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>