/
functions.php
53 lines (43 loc) · 1.38 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
<?php
/* BEGIN filters */
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
add_filter('post_limits', 'remove_limits');
function remove_limits() { return(""); }
/* END filters */
$polarity = 0;
function cmp_date($a, $b) {
if ($a['date'] == $b['date']) {
return (strcmp($a['post']->post_title, $b['post']->post_title));
}
return ($a['date'] > $b['date']) ? -1 : 1;
}
function get_images($id, $width) {
$args = array( 'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => null,
'post_parent' => $id
);
$attachments = get_posts($args);
$srcs = array();
foreach ($attachments as $attachment) {
if (substr($attachment->post_title, -4, 4) == $width) {
$src = wp_get_attachment_image_src($attachment->ID, 'full');
$src[3] = $attachment->post_title;
$srcs[] = $src;
}
}
$count = count($srcs);
if ($count) {
$src = $srcs[0][0];
$width = $srcs[0][1];
$height = $srcs[0][2];
$alt = $srcs[0][3];
$image = '<img src="'.$src.'" alt="'.$alt.'" />';
} else {
$image = '<img src="'.get_bloginfo('url').'/media/blank_'.$width.'.png" alt="Blank, '.$width.'" />';
}
return($image);
}
?>