/
tag.php
181 lines (134 loc) · 4.27 KB
/
tag.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
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
* The template for displaying Tag pages
*
* Used to display archive-type pages for posts in a tag.
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header();
// El objeto TAG que manejamos en la página
$tag = get_queried_object();
$tag_name = single_tag_title('', false);
$tag_slug = $tag->slug;
?>
<div id="cuerpo" class="container">
<?php
if (have_posts()):
?>
<header class="tag-header">
<div class="headline">
<h2 class="archive-title">
<?php printf(__('%s', 'twentyfourteen'), single_tag_title('', false)); ?>
</h2>
</div>
<?php
// MOSTRAMOS LA IMAGEN DE LA CATEGORÍA MEDIANTE EL PLUGIN CATEGORIES IMAGES
/* HAY QUE VALIDAR QUE TIENE URL, SI NO NO METO LA IMAGEN */
$sitiothumb = get_option('vcp_thumbnail');
$clase = '';
if ($sitiothumb == 'center')
$clase = 'center-block img-responsive img-cabecera';
else if ($sitiothumb == 'left')
$clase = 'pull-left img-responsive thumb';
else
$clase = 'img-responsive thumb';
// MOSTRAMOS LA IMAGEN DE LA CATEGORÍA MEDIANTE EL PLUGIN CATEGORIES IMAGES
if (function_exists('z_taxonomy_image_url') && z_taxonomy_image_url())
echo '<div class="' . $clase . '"><img id="logo-manual" src="' . z_taxonomy_image_url() . '" alt="' . single_cat_title('', false) . '"/></div>';
// Show an optional term description.
$term_description = term_description();
if (!empty($term_description)):
printf('<div class="taxonomy-description">%s</div>', $term_description);
endif;
?>
</header><!-- .archive-header -->
<?php
// Ponemos la información de volver.
printf('%s', vcp_volver($tag_slug));
// Pintamos las tags dado un título
printf('%s', vcp_tags($tag_name));
?>
<div class="headline">
<h2>Últimos Artículos en
<?php echo single_tag_title('', false) ?>
</h2>
</div>
<div class="row row-eq-height">
<?php
function get_excerpt_by_id2($post_id)
{
$the_post = get_post($post_id); //Gets post ID
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
$excerpt_length = 20; //Sets excerpt length by word count
$the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images
$words = explode(' ', $the_excerpt, $excerpt_length + 1);
if (count($words) > $excerpt_length):
array_pop($words);
array_push($words, '…');
$the_excerpt = implode(' ', $words);
endif;
$the_excerpt = '<p>' . $the_excerpt . '</p>';
return $the_excerpt;
}
$recent_posts = wp_get_recent_posts(array('tag' => $tag->slug, 'numberposts' => '6', 'post_status' => 'publish'));
$x = 0;
foreach ($recent_posts as $recent) {
?>
<div class="col-md-4 col-sm-6">
<div class="media">
<a class="pull-left" href="<?php echo get_permalink($recent["ID"]) ?>">
<div class="img-thumbnail">
<?php echo get_the_post_thumbnail($recent["ID"], array(75, 75)); ?>
</div>
</a>
<div class="media-body">
<h4 class="media-heading">
<?php echo '<a href="' . get_permalink($recent["ID"]) . '" title="' . esc_attr($recent["post_title"]) . '" >' . $recent["post_title"] . '</a>' ?>
</h4>
<?php echo get_excerpt_by_id2($recent["ID"]); ?>
</div>
</div>
</div>
<?php
}
?>
</div> <!-- #FIN DE ROW -->
<div class="row">
<div class="col-md-12">
<?php dynamic_sidebar('adspost'); ?>
</div>
</div>
<div class="headline">
<h2>Artículos
<?php echo single_tag_title('', false) ?>
</h2>
</div>
<?php
$args = array('posts_per_page' => 500, 'offset' => 0, 'tag' => $tag->slug);
$myposts = get_posts($args);
$numpost = ceil(sizeof($myposts) / 3);
$x = 0;
$html = '<div class="row"><div class="col-md-4">';
foreach ($myposts as $post) {
if (($x == $numpost) && ($numpost > 0)) {
$html .= '</div><div class="col-md-4">';
$x = 0;
}
$html = $html . '<span class="genericon genericon-document"></span><a href="' . get_permalink($post->post_id) . '">' . $post->post_title . '</a><br/>';
$x++;
}
//
$html .= "</div></div>";
echo $html;
?>
<?php
endif;
?>
</div><!-- #Fin Contenido Principal -->
<?php
get_footer();