-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
113 lines (85 loc) · 2.59 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
<?php
add_theme_support( 'menus' );
add_theme_support( 'html5', array( 'search-form', 'gallery', 'caption' ) );
function register_theme_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu')
)
);
}
add_action('init', 'register_theme_menus');
function tm_theme_styles() {
wp_enqueue_style('main_css', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'tm_theme_styles');
function tm_theme_js() {
//wp_enqueue_script('modernizr_js', get_template_directory_uri() . '/js/vendor/modernizr-2.8.3.min.js', '', '', false);
wp_enqueue_script('main_js', get_template_directory_uri() . '/js/min/main-min.js', array('jquery'), '', true);
}
add_action('wp_enqueue_scripts', 'tm_theme_js');
// Numbered Pagination
if ( !function_exists( 'tm_pagination' ) ) {
function tm_pagination() {
$prev_arrow = is_rtl() ? '→' : '←';
$next_arrow = is_rtl() ? '←' : '→';
global $wp_query;
$total = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if( $total > 1 ) {
if ( !$current_page = get_query_var('paged') )
$current_page = 1;
if ( get_option('permalink_structure') ) {
$format = 'page/%#%/';
} else {
$format = '&paged=%#%';
}
echo '<div class="pagination">';
echo paginate_links(array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => $format,
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'mid_size' => 3,
'type' => 'list',
'prev_text' => $prev_arrow,
'next_text' => $next_arrow,
) );
echo '</div>';
}
}
}
// Get parent category ... used to add class to articles for correct coloring
function get_first_category_ID() {
$category = get_the_category();
$category_parent_id = $category[0]->category_parent;
if ( $category_parent_id != 0 ) {
$category_parent = get_term( $category_parent_id, 'category' );
$css_slug = $category_parent->slug;
} else {
$css_slug = $category[0]->slug;
}
return $css_slug;
}
//Get recent headlines
function tm_get_recents($catID) {
$args = array(
'post_type' => 'post',
'cat' => $catID,
'posts_per_page' => '5'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo '<div class="recents-column">';
echo '<h4>Recent in ' . get_cat_name($catID) . '</h4>';
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li><a href="' . esc_url( get_permalink() ) . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
echo '</div>';
}
wp_reset_postdata();
}
?>