WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Jan 05 2012

Developing a Custom Post Type and a Custom Taxonomy in Genesis with Custom Pages, Part 4

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]

Written by Travis Smith · Categorized: Custom Post Types, Genesis

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Andy says

    August 13, 2012 at 6:48 am

    Thanks for this series of posts, I’ve followed them, very clear and all is going well. My only problem is the image that is generated on the post page. It links to the same post that is displayed. Is there an easy way to change the image link, ideally i would like to be able to add link into the permalink url and use a url redirect plugin to change where that link goes.

    Cheers

    Andy

    Reply
    • Travis Smith says

      August 13, 2012 at 9:57 am

      Easy is relative right? To me it may be, but to someone else, probably not. Since I am not really certain as to what you are speaking about, I can only make recommendations. However, you probably want to look into genesis_get_image() and see how you can modify that output to achieve your goals.

      Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in