Generally, custom post type archive pages like portfolio archives, don’t include a title. The reason for this is there’s no page template created when the custom post type is generated from the functions.php file. So you can’t simply add a title like you can with a page, post or standard archive page like which categories, tags and author archives use.
Rather than bore you with the reasons, i’ll simply give you the code which works.
Update: You can now add a archive settings page to any CPT using Genesis 2.0. Simply add these
'has_archive' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
Here’s an example of what the full code snippet should look like:
/** Create portfolio custom post type */
add_action( 'init', 'portfolio_post_type' );
function portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'child theme text' ),
'singular_name' => __( 'Portfolio', 'child theme text' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
)
);
}
This code will come in handy when using Genesis child themes like the Executive theme by StudioPress which uses a custom post type for the portfolio.
This code will display your custom post type archive title for your custom post type in the same way your category archive titles are displayed in the genesis_before_content hook position using the h1 heading size.
This code will also display your custom post type archive title but in the genesis_after_header hook position and aligns the title to the centre with a h2 heading size.
This code does the same as the code above however can be used for multiple custom post type archive titles. Not sure why you’d want to use the same titles on different custom post type archive pages but you may do for some reason.
The conditional tag used is:
is_post_type_archive
You can use different hooks with this code however you’ll find the genesis_post_title hook will also include the archive page title on posts attached to that custom post type archive which won’t be ideal.
This is the reason i have included the genesis_after_header and the genesis_before_content hooks as they only display the custom post type archive page title on the archive page and not on all the posts titles included in that archive.
Was This Tutorial Helpful?