Skip to content

Instantly share code, notes, and snippets.

@simbasounds
Last active January 10, 2016 14:49
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 simbasounds/b7848b0b9b41b3615f54 to your computer and use it in GitHub Desktop.
Save simbasounds/b7848b0b9b41b3615f54 to your computer and use it in GitHub Desktop.
Code to be added to Genesis functions.php to have a portfolio custom post type with archive support
<?php
/* Do not remove this line. Add your functions below. */
// Register Portfolio Items Custom Post Type
function register_portfolio() {
$labels = array(
'name' => _x( 'Portfolio Items', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Portfolio Item', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Portfolio Items', 'text_domain' ),
'parent_item_colon' => __( 'Parent Portfolio Item:', 'text_domain' ),
'all_items' => __( 'All Portfolio Items', 'text_domain' ),
'view_item' => __( 'View Portfolio Item', 'text_domain' ),
'add_new_item' => __( 'Add New Portfolio Item', 'text_domain' ),
'add_new' => __( 'Add New Portfolio Item', 'text_domain' ),
'edit_item' => __( 'Edit Portfolio Item', 'text_domain' ),
'update_item' => __( 'Update Portfolio Item', 'text_domain' ),
'search_items' => __( 'Search Portfolio Item', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'portfolio', 'text_domain' ),
'description' => __( 'Portfolio Item Sections', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'post-formats', 'genesis-seo', 'genesis-cpt-archives-settings', 'genesis-simple-sidebars',),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-portfolio',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'portfolio', $args );
}
add_action ('init', 'portfolio_sidebars_support');
function portfolio_sidebars_support() {
add_post_type_support( 'portfolio', 'genesis-simple-sidebars' );
}
// Hook into the 'init' action
add_action( 'init', 'register_portfolio', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment