-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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