-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathloop-greinasafn.php
65 lines (52 loc) · 2.42 KB
/
loop-greinasafn.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
<?php if ( have_posts() ) : ?>
<div class="grid gutter greinasafn">
<?php while ( have_posts() ) : the_post(); ?>
<?php // Get category
$cat_name = "Grein";
$cat_class = "generic";
$category = get_the_category();
// Excluded categories
$excluded = array("forsida", 'panorama-2', 'excluded');
$cat_names = array();
$cat_slugs = array();
for ($i = 0; $i < sizeof($category); $i++) {
if ($category[$i]) {
if (!in_array($category[$i]->slug, $excluded)) {
array_push($cat_names, $category[$i]->cat_name);
array_push($cat_slugs, $category[$i]->slug);
}
}
}
if (sizeof($cat_names)){
$cat_name = $cat_names[0];
$cat_class = $cat_slugs[0];
}
$title = get_the_title();
// if (strlen($title) > 87) {
// $list = split(':', $title);
// if (count($list) <= 1) {
// } else {
// $title = $list[1];
// }
// }
if (strlen($title) > 87) {
$title = substr($title, 0, 86);
$title = $title . '…';
}
?>
<div class="col s1of3 grein">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php if (has_post_thumbnail()): ?>
<?php the_post_thumbnail('sidebar', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
'class' => 'image'
)); ?>
<?php endif; ?>
<div class="grein-category <?php echo $cat_class; ?>"><?php echo $cat_name; ?></div>
<h2><?php echo $title; ?></h2>
</a>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>