Skip to content

Instantly share code, notes, and snippets.

@robincornett
Last active May 8, 2018 22:28
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 robincornett/eec3963e1a3e7ffcc4ade5629c3d27fd to your computer and use it in GitHub Desktop.
Save robincornett/eec3963e1a3e7ffcc4ade5629c3d27fd to your computer and use it in GitHub Desktop.
Use Six/Ten Press helper functions to easily register custom post types and taxonomies.
<?php
add_action( 'sixtenpress_setup', 'prefix_register_resource_post_type' );
/**
* Register a resource custom content type with custom labels, icon, and taxonomy.
* Requires Six/Ten Press 2.1.0.
*/
function prefix_register_resource_post_type() {
$post_type = 'resource';
$args = array(
'labels' => array(
'singular' => __( 'Resource', 'prefix' ),
'plural' => __( 'Resources', 'prefix' ),
),
'menu_position' => 10,
'menu_icon' => 'dashicons-schedule',
'taxonomies' => array( 'audience' ),
);
sixtenpress_register_post_type( $post_type, $args );
}
add_action( 'sixtenpress_setup', 'prefix_register_resource_taxonomy' );
/**
* Register an audience taxonomy with custom labels for use with the resource content type.
* Requires Six/Ten Press 2.1.0
*/
function prefix_register_resource_taxonomy() {
$taxonomy = 'audience';
$args = array(
'labels' => array(
'singular' => __( 'Audience', 'prefix' ),
'plural' => __( 'Audiences', 'prefix' ),
),
);
sixtenpress_register_taxonomy( $taxonomy, 'resource', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment