-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
212 lines (162 loc) · 4.71 KB
/
functions.php
File metadata and controls
212 lines (162 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/*
==========================================
Include scripts
==========================================
*/
function awesome_script_enqueue() {
//css
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.4', 'all');
wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/awesome.css', array(), '1.0.0', 'all');
//js
wp_enqueue_script('jquery');
wp_enqueue_script('bootstrapjs', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.3.4', true);
wp_enqueue_script('customjs', get_template_directory_uri() . '/js/awesome.js', array(), '1.0.0', true);
}
add_action( 'wp_enqueue_scripts', 'awesome_script_enqueue');
/*
==========================================
Activate menus
==========================================
*/
function awesome_theme_setup() {
add_theme_support('menus');
register_nav_menu('primary', 'Primary Header Navigation');
register_nav_menu('secondary', 'Footer Navigation');
}
add_action('init', 'awesome_theme_setup');
/*
==========================================
Theme support function
==========================================
*/
add_theme_support('custom-background');
add_theme_support('custom-header');
add_theme_support('post-thumbnails');
add_theme_support('post-formats',array('aside','image','video'));
add_theme_support('html5',array('search-form'));
/*
==========================================
Sidebar function
==========================================
*/
function awesome_widget_setup() {
register_sidebar(
array(
'name' => 'Sidebar',
'id' => 'sidebar-1',
'class' => 'custom',
'description' => 'Standard Sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
)
);
}
add_action('widgets_init','awesome_widget_setup');
/*
==========================================
Include Walker file
==========================================
*/
require get_template_directory() . '/inc/walker.php';
/*
==========================================
Head function
==========================================
*/
function awesome_remove_version() {
return '';
}
add_filter('the_generator', 'awesome_remove_version');
/*
==========================================
Custom Post Type
==========================================
*/
function awesome_custom_post_type (){
$labels = array(
'name' => 'Portfolio',
'singular_name' => 'Portfolio',
'add_new' => 'Add Item',
'all_items' => 'All Items',
'add_new_item' => 'Add Item',
'edit_item' => 'Edit Item',
'new_item' => 'New Item',
'view_item' => 'View Item',
'search_item' => 'Search Portfolio',
'not_found' => 'No items found',
'not_found_in_trash' => 'No items found in trash',
'parent_item_colon' => 'Parent Item'
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail',
'revisions',
),
//'taxonomies' => array('category', 'post_tag'),
'menu_position' => 5,
'exclude_from_search' => false
);
register_post_type('portfolio',$args);
}
add_action('init','awesome_custom_post_type');
function awesome_custom_taxonomies() {
//add new taxonomy hierarchical
$labels = array(
'name' => 'Fields',
'singular_name' => 'Field',
'search_items' => 'Search Fields',
'all_items' => 'All Fields',
'parent_item' => 'Parent Field',
'parent_item_colon' => 'Parent Field:',
'edit_item' => 'Edit Field',
'update_item' => 'Update Field',
'add_new_item' => 'Add New Work Field',
'new_item_name' => 'New Field Name',
'menu_name' => 'Fields'
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'field' )
);
register_taxonomy('field', array('portfolio'), $args);
//add new taxonomy NOT hierarchical
register_taxonomy('software', 'portfolio', array(
'label' => 'Software',
'rewrite' => array( 'slug' => 'software' ),
'hierarchical' => false
) );
}
add_action( 'init' , 'awesome_custom_taxonomies' );
/*
==========================================
Custom Term Function
==========================================
*/
function awesome_get_terms( $postID, $term ){
$terms_list = wp_get_post_terms($postID, $term);
$output = '';
$i = 0;
foreach( $terms_list as $term ){ $i++;
if( $i > 1 ){ $output .= ', '; }
$output .= '<a href="' . get_term_link( $term ) . '">'. $term->name .'</a>';
}
return $output;
}