Custom post type and taxonomies
-
I am trying to create a custom post type of ‘representative’ and I will assign them to states. When I post a new representative, I only want a list of states to show in the drop down. No all post categories.
//Representatives post type function my_custom_post_reps() { $labels = array( 'name' => _x( 'Representative', 'post type general name' ), 'singular_name' => _x( 'Representative', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Representative' ), 'add_new_item' => __( 'Add New Representative' ), 'edit_item' => __( 'Edit Representative' ), 'new_item' => __( 'New Representative' ), 'all_items' => __( 'All Representatives' ), 'view_item' => __( 'View Representatives' ), 'search_items' => __( 'Search Representatives' ), 'not_found' => __( 'No representative found' ), 'not_found_in_trash' => __( 'No representative found in the Trash' ), 'parent_item_colon' => β, 'menu_name' => 'Representative' ); $args = array( 'labels' => $labels, 'description' => 'representative specific data', 'public' => true, 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments','custom-fields' ), 'has_archive' => true, 'show_in_rest' => true, 'show_ui'=>true, 'show_in_menu'=>true, 'taxonomies' => array('states') ); register_post_type( 'representative', $args ); register_taxonomy_for_object_type('category', 'representative'); register_taxonomy_for_object_type('post_tag', 'representative'); } add_action( 'init', 'my_custom_post_reps' , 0 );
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Custom post type and taxonomies’ is closed to new replies.