/
functions.php
169 lines (130 loc) · 4.46 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/*
Theme Name: TheWishingWellWA
Authors:
Site URI:
Description: This is a custom theme developed for the ITC210/WEB210 class at SCC.
Version: 1.0
*/
// Register sidebars:
register_sidebar(array(
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
// Get my title tag:
function get_my_title_tag() {
global $post;
if (is_front_page()) {
bloginfo('description');
}
else if (is_page() || is_single()) {
the_title();
}
else {
bloginfo('description');
}
if ($post->post_parent) {
echo ' | ';
echo get_the_title($post->post_parent);
}
echo ' | ';
bloginfo('name'); // site name
echo ' | ';
echo 'Seattle, WA'; // Write the city and state
}
// Register menus:
register_nav_menus(array(
'main-menu' => __('Main'),
'footer-menu' => __('Footer Menu'),
'social-menu' => __('Social Menu')
));
// Enable Featured Images & Post Thumbnails:
add_theme_support('post-thumbnails');
// Add Excerpt support:
add_post_type_support('page', 'excerpt');
// Remove Inline Styles from Captions
add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
}
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
if ( $output != '' )
return $output;
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $content;
if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" >'
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
//
//Create Custom Image Sizes
add_image_size('featured-spotlight', 300, 300, array("left", "top")); //300 x 300, hard crop
add_image_size('blog-spotlight', 220, 175, array("left", "top")); //220 x 175, hard crop
add_image_size('gateway-feature', 940, 330, array("center", "center")); // 940 x 330, hard crop
//Get Child Pages
function get_child_pages(){
global $post;
rewind_posts(); //stops any previous loops
query_posts(array('post_type' => 'page', 'posts_per_page'=> -1, 'post_status' => publish, 'post_parent' => $post->ID,'order'=> 'ASC','orderby' =>'menu_order'));//query and order child pages
while (have_posts()) : the_post();
$childPermalink = get_permalink($post->ID); //post permalink
$childID = $post->ID; //post it
$childTitle = $post->post_title; //post title
$childExcerpt = $post->post_excerpt; //post excerpt
$childImage = get_the_post_thumbnail($page->ID, 'featured-spotlight') ; //post thumbnail
echo '<div class="tile">';
echo '<div class="tile-image">' . $childImage . '</div>';
echo '<h1 id="cta-h1"><a href="'.$childPermalink.'">' .$childTitle.'</a></h1>';
echo '<p class="caption"><a href="'.$childPermalink.'"><span>'. $childExcerpt . '</span></a></p>';
echo '</div>';
endwhile;
wp_reset_query();// reset query
}
function get_featured_image() {
global $post;
$theImage = get_the_post_thumbnail($page->ID, 'medium');
$theLink = get_post_meta($post->ID, 'featured-image-link', true);
echo '<figure class="featured-image">';
if ($theLink) {
echo '<a href="'.$theLink.'" target="_blank" title="View: '.$theLink.'">'.$theImage.'</a>';
} else {
echo $theImage;
}
echo '</figure>';
}
function custom_excerpt_length( $length ) {
return 25;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function new_excerpt_more( $more ) {
return ' <a id="read-more" href="' . get_permalink( get_the_ID() ) .'">' . __( ' [<i>Read More...</i>]', 'your-text-domain' ) . '</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
function front_page_CTA($slug) {
$page_data = new WP_Query(array( "name" => $slug, "post_type" => "page") );
$page_id = $page_data->post->ID;
$page_link = get_permalink($page_id);
$tagline = get_post_meta($page_id, 'Tagline','true');
$title = get_the_title($page_id);
$image = get_the_post_thumbnail($page_id,'featured-spotlight');
echo '<div class="tile-image">' . $image . '</div>';
?>
<h1 id="cta-h1"><a href="<?= $page_link ?>">
<?= $title ?></a></h1>
<p class="caption"><a href="<?= $page_link ?>"><span><?= $tagline ?></span></a></p>
<?php
}
?>