Skip to content

Instantly share code, notes, and snippets.

@iamkingsleyf
Forked from rfmeier/functions.php
Created May 16, 2014 06:55
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 iamkingsleyf/b4179de438cb0750b6d3 to your computer and use it in GitHub Desktop.
Save iamkingsleyf/b4179de438cb0750b6d3 to your computer and use it in GitHub Desktop.
<?php
// register the custom post type widget area
genesis_register_sidebar( array(
'id' => 'cpt-archive-sidebar',
'name' => __( 'Custom Post Type Sidebar' ),
'description' => __( 'Display this sidebar on your custom post type archive page.' ),
) );
add_action( 'genesis_before_sidebar_widget_area', 'cpt_genesis_before_sidebar_widget_area' );
/**
* Callback for Genesis 'genesis_before_sidebar_widget_area' action.
*
* If on custom post type archive page, remove default sidebar (widget area).
*
* @author Ryan Meier http://www.rfmeier.net/
* @package Genesis
* @category Widget Area
*/
function cpt_genesis_before_sidebar_widget_area(){
// if not on custom post type archive page, return
if( is_post_type_archive( 'custom_post_type' ) ){
// remove default widget areas if on post type archive pages
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
}
}
add_action( 'genesis_sidebar', 'cpt_genesis_sidebar' );
/**
* Callback for Genesis 'genesis_sidebar' action.
*
* If on custom post type archive page, display cpt widget area
*
* @author Ryan Meier http://www.rfmeier.net/
* @package Genesis
* @category Widget Area
*/
function cpt_genesis_sidebar(){
// if not on custom post type archive page, return
if( ! is_post_type_archive( 'custom_post_type' ) )
return;
// display the post type archive widget area
genesis_widget_area( 'cpt-archive-sidebar' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment