/
template-tag-index.php
executable file
·100 lines (100 loc) · 3.46 KB
/
template-tag-index.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
<?php
/*
* Template Name: tag Index
*/
get_header();
?>
<div class="jumbotron">
<div class="container-fluid clearfix">
<h1>
<?php
printf(
esc_html__( 'Tags List', 'multiloquent' )
);
?>
</h1>
</div>
</div>
<div class="container-fluid clearfix">
<!-- google_ad_section_start-->
<article>
<?php
// Make an array from A to Z.
// $characters = range('a', 'z');
// Check if $characters exists and ensure that it is an array.
// if ($characters && is_array($characters)) {
// foreach ($characters as $index => $character) {
// Get the tag information for each characters in the array.
$tags = get_tags(
array(
'order' => 'ASC',
)
);
// print_r($tags);
if ( $index != 0 && $index % 4 == 0 ) {
$html = "<div class='post-tags clearfix' style='clear:left;'>";
} else {
$html = "<div class='post-tags clearfix'>";
}
// Output the character and use it as the title.
$html .= "<h3 class='title'>{$character}</h3>";
// Output the markup for each tag found for each character.
if ( $tags ) {
$html .= '<ul class="thumbnails row">';
$first_colour = $multiloquent->multiloquent_get_random_solid_class( $tag->slug );
foreach ( (array) $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$second_colour = $multiloquent->multiloquent_get_random_blue_class( $tag->slug );
if ( $tag->slug == $second_colour ) {
$tile_colour = $second_colour;
} else {
$tile_colour = $first_colour;
}
if ( strlen( $tag->name ) > '30' ) {
$html .= '<li class="tag-item tile tile-double double-height col-sm-6 col-md-4 col-lg-3 ' . $tile_colour . '" onclick="javascript:window.location.href=';
$html .= "'" . $tag_link . "'";
$html .= '" >';
} elseif ( strlen( $tag->name ) > '10' ) {
$html .= '<li class="tag-item tile tile-double col-sm-6 col-md-4 col-lg-3 ' . $tile_colour . '" onclick="javascript:window.location.href=';
$html .= "'" . $tag_link . "'";
$html .= '" >';
} elseif ( strlen( $tag->name ) > '5' ) {
$html .= '<li class="tag-item tile tile-double col-sm-6 col-md-4 col-lg-3 ' . $tile_colour . '" onclick="javascript:window.location.href=';
$html .= "'" . $tag_link . "'";
$html .= '" >';
} else {
$html .= '<li class="tag-item tile col-sm-6 col-md-4 col-lg-3 ' . $tile_colour . '" onclick="javascript:window.location.href=';
$html .= "'" . $tag_link . "'";
$html .= '" >';
}
if ( strlen( $tag->name ) > '30' ) {
$html .= '<h2 class="nowrap"><a href="' . $tag_link . '" title="View all ' . $tag->count . ' articles with the tag of ' . $tag->name . '" >';
$html .= "{$tag->name}</a></h2>";
} elseif ( strlen( $tag->name ) > '10' ) {
$html .= '<h3><a href="' . $tag_link . '" title="View all ' . $tag->count . ' articles with the tag of ' . $tag->name . '" >';
$html .= "{$tag->name}</a></h3>";
} else {
$html .= '<h2><a href="' . $tag_link . '" title="View all ' . $tag->count . ' articles with the tag of ' . $tag->name . '" >';
$html .= "{$tag->name}</a></h2>";
}
$html .= '<span class="badge">' . $tag->count . '</span>';
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</div>';
// Output the markup for the current character.
echo $html;
// Increment the index by 1.
$index++;
// }
// }
?>
</article>
<!-- google_ad_section_end-->
<?php
get_template_part( 'advert' );
?>
</div>
<?php
get_footer();