Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created February 18, 2019 15:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save billerickson/fe4c68b5ed34cfec10c958835bf01962 to your computer and use it in GitHub Desktop.
<?php
/**
* Team
*
* @package CoreFunctionality
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/
class EA_Team {
/**
* Initialize all the things
*
* @since 1.2.0
*/
function __construct() {
add_action( 'init', array( $this, 'register_cpt' ) );
add_filter( 'genesis_cpt_crumb', array( $this, 'team_crumb' ), 10, 2 );
}
/**
* Register the custom post type
*
* @since 1.2.0
*/
function register_cpt() {
$labels = array(
'name' => 'Team',
'singular_name' => 'Team Member',
'add_new' => 'Add New',
'add_new_item' => 'Add New Team Member',
'edit_item' => 'Edit Team Member',
'new_item' => 'New Team Member',
'view_item' => 'View Team Member',
'search_items' => 'Search Team Members',
'not_found' => 'No Team Members found',
'not_found_in_trash' => 'No Team Members found in Trash',
'parent_item_colon' => 'Parent Team Member:',
'menu_name' => 'Team',
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => array( 'slug' => 'team', 'with_front' => false ),
'menu_icon' => 'dashicons-groups', // https://developer.wordpress.org/resource/dashicons/
);
register_post_type( 'team', $args );
}
function team_crumb( $crumb, $args ) {
// Only run on team post
if( ! is_singular( 'team' ) )
return $crumb;
$crumbs = explode( $args['sep'], $crumb );
$crumbs[0] = '<a href="' . home_url( 'team-members' ) . '">' . $crumbs[0] . '</a>';
$crumb = implode( $args['sep'], $crumbs );
return $crumb;
}
}
new EA_Team();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment