Last active
October 27, 2022 21:57
-
-
Save tevashov/5172449 to your computer and use it in GitHub Desktop.
Add custom post type with taxonomy #WP
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
| function post_type_albums() { | |
| register_post_type( | |
| 'albums', | |
| array( 'label' => __('Albums'), | |
| 'public' => true, | |
| 'show_ui' => true, | |
| 'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'comments') | |
| ) | |
| ); | |
| // Custom Taxonomy for Genres: categories specific for this post type | |
| register_taxonomy( 'genres', 'albums', array( 'hierarchical' => true, 'label' => __('Genres') ) ); | |
| // Custom Taxonomy for Performer: add tags specific for this post type. | |
| register_taxonomy( | |
| 'performer', 'albums', | |
| array('hierarchical' => false, | |
| 'label' => __('Performer'), | |
| 'query_var' => 'performer', | |
| 'rewrite' => array('slug' => 'performer') | |
| ) | |
| ); | |
| } | |
| add_action('init', 'post_type_albums'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment