Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created May 7, 2012 00:11
Show Gist options
  • Save jeremyfelt/2625099 to your computer and use it in GitHub Desktop.
Save jeremyfelt/2625099 to your computer and use it in GitHub Desktop.
A very basic example of register_post_type() in WordPress
<?php
/*
* Creates a custom post type with the key 'prefix_post_type', with a basic
* configuration that provides for public access on the front end and admin.
*
*/
add_action( 'init', 'prefix_register_post_type' );
function prefix_register_post_types() {
$public_pt_args = array(
'label' => 'My Post Type',
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'show_in_menu' => true,
'has_archive' => true,
'rewrite' => true,
'query_var' => true,
);
register_post_type( 'prefix_post_type', $public_pt_args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment