Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
Last active March 8, 2016 17:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lumpysimon/5a68f561fd2381e64efe to your computer and use it in GitHub Desktop.
Save lumpysimon/5a68f561fd2381e64efe to your computer and use it in GitHub Desktop.
Example WordPress custom post type and taxonomy definitions using Extended CPTs and Extended Taxos
register_extended_post_type(
'newsletter',
array(
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 45,
'quick_edit' => false,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'admin_cols' => array(
'newsletter-image' => array(
'title' => 'Featured image',
'featured_image' => 'thumbnail',
'width' => '150'
),
'newsletter-sent' => array(
'title' => 'Sent',
'meta_key' => 'nfa-newsletter-sent',
'date_format' => true
),
'newsletter-recipients' => array(
'title' => 'Recipients',
'function' => array( $this, 'recipients_col' )
),
'newsletter-type' => array(
'title' => 'Type',
'taxonomy' => 'newsletter-type'
),
'newsletter-stats' => array(
'title' => 'Statistics',
'function' => array( $this, 'stats_col' )
)
),
'admin_filters' => array(
'newsletter_type' => array(
'title' => 'View by type',
'taxonomy' => 'newsletter-type'
)
)
)
);
register_extended_taxonomy(
'newsletter-type',
'newsletter',
array(
'hierarchical' => false,
'show_ui' => true,
'meta_box' => 'radio'
),
array(
'singular' => 'Type',
'plural' => 'Types',
'slug' => 'newsletter-type'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment