Project

General

Profile

Support #4026 » functions.php

Paul Hebert, 2015-04-28 12:53 PM

 
1
<?php
2
// register custom post type to work with
3
function wpmudev_create_post_type() {
4
// set up labels
5
$labels = array(
6
'name' => 'Course Evaluations',
7
'singular_name' => 'Evaluation',
8
'add_new' => 'Add Evaluation',
9
'add_new_item' => 'Add New Course Evaluation',
10
'edit_item' => 'Edit Evaluation',
11
'new_item' => 'New Evaluation',
12
'all_items' => 'All Evaluations',
13
'view_item' => 'View Evaluation',
14
'search_items' => 'Search Evaluations',
15
'not_found' => 'No Evaluations Found',
16
'not_found_in_trash' => 'No Evaluations found in Trash',
17
'parent_item_colon' => '',
18
'menu_name' => 'Course Evaluations',
19
);
20
//register post type
21
register_post_type( 'evaluation', array(
22
'labels' => $labels,
23
'has_archive' => true,
24
'public' => true,
25
'supports' => array( 'title', 'editor', 'thumbnail'),
26
'taxonomies' => array( 'Professor', 'Semester'),
27
'exclude_from_search' => false,
28
'capability_type' => 'post',
29
'rewrite' => array( 'slug' => 'evaluation' ),
30
)
31
);
32
}
33
add_action( 'init', 'wpmudev_create_post_type' );
34

    
35
// hook into the init action and call CourseEvaluation_taxonomies when it fires
36
add_action( 'init', 'create_CourseEvaluation_taxonomies', 0 );
37

    
38
// create two taxonomies, Professor and Semester for the post type "Course Evaluations"
39
function create_courseevaluation_taxonomies() {
40
	// Add new taxonomy, make it hierarchical (like categories)
41
	$labels = array(
42
		'name'              => _x( 'Professor', 'taxonomy general name' ),
43
		'singular_name'     => _x( 'Professor', 'taxonomy singular name' ),
44
		'search_items'      => __( 'Search Professors' ),
45
		'all_items'         => __( 'All Professors' ),
46
		'parent_item'       => __( 'Parent Professor name' ),
47
		'parent_item_colon' => __( 'Parent Professor name:' ),
48
		'edit_item'         => __( 'Edit Professor name' ),
49
		'update_item'       => __( 'Update Professor name' ),
50
		'add_new_item'      => __( 'Add New Professor' ),
51
		'new_item_name'     => __( 'New Professor ' ),
52
		'menu_name'         => __( 'Professor' ),
53
	);
54

    
55
	$args = array(
56
		'hierarchical'      => false,
57
		'labels'            => $labels,
58
		'show_ui'           => true,
59
		'show_admin_column' => true,
60
		'query_var'         => true,
61
		'rewrite'           => array( 'slug' => 'Professor' ),
62
	);
63

    
64
	register_taxonomy( 'Professor', array( 'CourseEvaluation' ), $args );
65

    
66
	$labels = array(
67
		'name'                       => _x( 'Semester', 'taxonomy general name' ),
68
		'singular_name'              => _x( 'Semester', 'taxonomy singular name' ),
69
		'search_items'               => __( 'Search Semesters' ),
70
		'all_items'                  => __( 'All Semesters' ),
71
		'parent_item'       	     => __( 'Parent Semester name' ),
72
		'parent_item_colon'          => __( 'Parent Semester name:' ),
73
		'edit_item'                  => __( 'Edit Semester' ),
74
		'update_item'                => __( 'Update Semester' ),
75
		'add_new_item'               => __( 'Add New Semester' ),
76
		'new_item_name'              => __( 'New Semester' ),
77
		'menu_name'                  => __( 'Semester' ),
78
	);
79

    
80
	$args = array(
81
		'hierarchical'      => false,
82
		'labels'            => $labels,
83
		'show_ui'           => true,
84
		'show_admin_column' => true,
85
		'query_var'         => true,
86
		'rewrite'           => array( 'slug' => 'Semester' ),
87
	);
88

    
89
	register_taxonomy( 'Semester', 'CourseEvaluation', $args );
90
}
91
?>
(1-1/2)