Skip to content

Instantly share code, notes, and snippets.

@jesgs
Last active October 13, 2015 04:08
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 jesgs/4137028 to your computer and use it in GitHub Desktop.
Save jesgs/4137028 to your computer and use it in GitHub Desktop.
WordPress Post-Type Framework Example
<?php
add_action('init', 'theme_post_types');
/**
* Reqister Post-Types
*
* @return void
*/
function theme_post_types()
{
//example #1:
$videos = new JesGS_PostType();
$videos
->set_name('mytheme_videos')
->set_singlename('Video')
->set_pluralname('Videos')
->set_arguments()
->init();
// example #2:
// init() method is called automatically
$books = new JesGS_PostType(array(
'name' => 'mytheme_books',
'singlename' => 'Book',
'pluralname' => 'Books',
'arguments' => array(
'supports' => array(
'title',
'editor',
),
'has_archive' => true,
'rewrite' => array(
'slug' => 'books',
),
),
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment