Now, in Developing a Custom Post Type and a Custom Taxonomy in Genesis with Custom Pages, Part 1, we have the registration of the custom post type, custom taxonomy and the addition of the metaboxes. In Part 2, we discussed the Single Page Template for the custom post type. In Part 3, we discussed the Taxonomy Template for the custom taxonomy. For good measure, let's create a basic page template to wrap this all up. This will create a front page of sorts for the custom taxonomy and the single custom post type pages.
A. File Setup
First, create the file as page-{whatever}.php (WordPress Codex). While you can use page-{slug}.php, this can cause some unexpected issues. So naming it page-{whatever}.php forces the user to assign it via the page templates area. So in our case, it will be page-brakes.php.
B. Template Name
The first thing you must enter with any page template is the Template Name.
[php]<?php
/*
*Template Name: Disc Brakes Template
*/
[/php]
B. Menu Move
Now, for this example, I want to use a menu system. So I will be using the secondary menu system to accomplish this, and I want this to appear below the title.
[php]<?php
// Place the secondary navigation menu below the title
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_after_post_title', 'genesis_do_subnav' );
// Enable the secondary navigation menu for single post type
add_filter('genesis_options', 'wps_define_genesis_setting' , 10, 2);
function wps_define_genesis_setting( $options, $setting ) {
if( $setting == GENESIS_SETTINGS_FIELD ) {
$options['subnav'] = 1;
}
return $options;
}
[/php]
If you notice, I programmatically turn on the secondary menu. However, again, in Genesis > Theme Settings, site-wide, I have the secondary navigation system turned off. Now, for this page template, I have selectively turned it on.
If you use the secondary navigation for your site, simply register a new navigation system and then add it. See the previous tutorial for this information.
C. Include the Genesis Framework **VERY IMPORTANT
[php]<?php
genesis();
[/php]
So here is our finished product: page-brakes.php
[php]
<?php
/*
*Template Name: Disc Brakes Template
*/
// Place the secondary navigation menu below the title
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_after_post_title', 'genesis_do_subnav' );
// Enable the secondary navigation menu for single post type
add_filter('genesis_options', 'wps_define_genesis_setting' , 10, 2);
function wps_define_genesis_setting( $options, $setting ) {
if( $setting == GENESIS_SETTINGS_FIELD ) {
$options['subnav'] = 1;
}
return $options;
}
genesis();
[/php]