Skip to content

Instantly share code, notes, and snippets.

@robincornett

robincornett/functions.php Secret

Last active May 8, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.