Last active
March 8, 2016 17:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://github.com/johnbillion/extended-cpts and https://github.com/johnbillion/extended-taxos