Skip to content

Instantly share code, notes, and snippets.

@pudgereyem
Created December 27, 2013 15:09
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 pudgereyem/8148250 to your computer and use it in GitHub Desktop.
Save pudgereyem/8148250 to your computer and use it in GitHub Desktop.
PHP, WORDPRESS: Register post type
<?php
/* Init post types */
add_action( 'init', 'wtf_post_resource_register' );
/*--------------------------------------------------------------------------------------
*
* wtf_post_resource_register
*
* @author Victor Meyer
* @since 0.1
*
*-------------------------------------------------------------------------------------*/
function wtf_post_resource_register() {
$labels = array(
'name' => __( 'Resources', 'wtf' ),
'singular_name' => __( 'Resource', 'wtf' ),
'add_new' => __( 'Add New', 'wtf' ),
'add_new_item' => __( 'Add New Resource', 'wtf' ),
'edit_item' => __( 'Edit Resource', 'wtf' ),
'new_item' => __( 'New Resource', 'wtf' ),
'view_item' => __( 'View Resource', 'wtf' ),
'search_items' => __( 'Search Resources', 'wtf' ),
'not_found' => __( 'No resources found', 'wtf' ),
'not_found_in_trash' => __( 'No resources found in Trash', 'wtf' ),
'parent_item_colon' => __( 'Parent Resource:', 'wtf' ),
'menu_name' => __( 'Resources', 'wtf' )
);
$arguments = array(
'labels' => $labels,
'description' => __( 'Resource post type', 'wtf' ),
'public' => true,
'hierarchical' => true, // Enable custom menu order
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'revisions' ),
'rewrite' => array( 'with_front' => false ) // Exclude front base
);
register_post_type( 'resource', $arguments );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment