-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
153 lines (83 loc) · 2.75 KB
/
functions.php
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
<?php
// functions.php
function learningWordPress_resources() {
wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'learningWordPress_resources');
// Get top ancestor
function get_top_ancestor_id() {
global $post;
if ($post->post_parent) {
$ancestors = array_reverse(get_post_ancestors($post->ID));
return $ancestors[0];
}
// If doesn't have a parent page
return $post->ID;
}
// Does page have children?
function has_children() {
global $post;
$pages = get_pages('child_of=' . $post->ID);
return count($pages);
}
// Customize excerpt word count length
function custom_excerpt_length() {
return 25;
}
add_filter('excerpt_length', 'custom_excerpt_length');
// Theme Setup
function learningWordPress_setup() {
// Navigation Menus
register_nav_menus(array(
'primary' => __( 'Primary Menu'),
'footer' => __( 'Footer Menu'),
));
// Add featured image support
add_theme_support('post-thumbnails');
// Register new image sizes
add_image_size('small-thumbnail', 180, 120, true); // hard crop
add_image_size('banner-image', 920, 210, array('left','top'));
add_image_size('latest-thumb', 100, 100, true);
// Add post format support
add_theme_support('post-formats', array('aside', 'gallery', 'link'));
}
add_action('after_setup_theme', 'learningWordPress_setup');
// Add our widget locations
function ourWidgetsInit() {
// register sidebar widget locations
register_sidebar( array(
'name' => 'Sidebar',
'id' => 'sidebar1',
'before_widget' => '<div class="widget_item">',
'after_widget' => '</div>',
'before_title' => '<h4 class="my-special-class">',
'after_title' => '</h4>'
));
register_sidebar( array(
'name' => 'Footer Area 1',
'id' => 'footer1',
'before_widget' => '<div class="widget_item">',
'after_widget' => '</div>',
'before_title' => '<h4 class="my-special-class">',
'after_title' => '</h4>'
));
register_sidebar( array(
'name' => 'Footer Area 2',
'id' => 'footer2',
'before_widget' => '<div class="widget_item">',
'after_widget' => '</div>',
));
register_sidebar( array(
'name' => 'Footer Area 3',
'id' => 'footer3',
'before_widget' => '<div class="widget_item">',
'after_widget' => '</div>',
));
register_sidebar( array(
'name' => 'Footer Area 4',
'id' => 'footer4',
'before_widget' => '<div class="widget_item">',
'after_widget' => '</div>',
));
}
add_action('widgets_init', 'ourWidgetsInit');