File: /datos/www/www.colombia.co/public_html/wp-content/themes/colombia2016/downloads.php
<?php
/**
* Template Name: Downloads
*/
get_header();
$locale = get_locale();
if($locale == "es_CO"){
$category_ID = get_category_by_slug('descargas')->term_id;
}
else if($locale == "en_US"){
$category_ID = get_category_by_slug('downloads')->term_id;
}
$subcats = get_categories(array(
'child_of' => $category_ID
)
);
while ( have_posts() ) : the_post();
?>
<main role="main" class="l-flex category-descargas">
<div id="modal">
<button id="close-modal" type="button">+</button>
<audio id="audio" src="" controls></audio>
<video id="video" src="" controls></video>
</div>
<div id="category-header">
<div class="l-container l-flex">
<div class="cat-header-container">
<?php
if(get_the_content()){
?>
<h2 class="cat-name"><?php the_title(); ?></h2>
<h1 class="cat-title"><?php the_content(); ?></h1>
<?php
}
else{
?>
<h1 class="cat-title"><?php the_title(); ?></h1>
<?php } ?>
</div>
</div>
</div>
<div id="content-wrapper" class="l-container l-flex">
<section id="downloads">
<?php
if(is_array($subcats)&&!empty($subcats)){
echo '<select id="downloads-filter">';
echo '<option value="all">'.__('Seleccione la categorÃa', 'colombia').'</option>';
foreach($subcats as $category){
echo '<option value="category-'.$category->slug.'">'.$category->name.'</option>';
}
echo '</select>';
foreach($subcats as $category){
$query = new WP_Query(
array(
'post_type' => 'download',
'posts_per_page' => '-1',
'cat' => $category->term_id
)
);
echo '<div class="category-wrapper category-'.$category->slug.'">';
echo '<h3 class="subcategory-name">'.$category->name.'</h3>';
if($query->have_posts()) : while($query->have_posts()){
$query->the_post();
?>
<article <?php post_class('download'); ?> id="post-<?php the_ID(); ?>">
<figure class="download-img">
<?php the_post_thumbnail(); ?>
</figure>
<div class="download-info">
<h2 class="download-title"><?php the_title(); ?></h2>
<div class="download-actions">
<!-- se agrega linea para realizar seguimiento a las descargas con google analytics en el evento onclick usando el titulo del post como referencia -->
<div class="download-content"><?php the_content(); ?></div>
<a href=""onClick="ga('send', 'event', 'descargas_rediseno_2016', 'descargar', '<?php the_title(); ?>');" class="download-action download-action-play" ><i class="icon-volume"></i><span><?php _e('Escuchar demo', 'colombia'); ?></span></a>
<a href="" class="download-action download-action-play-video"><i class="icon-volume"></i><span><?php _e('Ver video', 'colombia'); ?></span></a>
<!-- se agrega linea para realizar seguimiento a las descargas con google analytics en el evento onclick usando el titulo del post como referencia -->
<a href="" onClick="ga('send', 'event', 'descargas_rediseno_2016', 'descargar', '<?php the_title(); ?>');" target="_blank" class="download-action download-action-download" download><i class="icon-downloads"></i><span><?php _e('Descargar archivo', 'colombia'); ?></span></a>
</div>
</div>
</article>
<?php
}
endif;
echo '</div>';
wp_reset_query();
}
}
?>
</section>
<?php get_sidebar(); ?>
</div>
</main>
<?php endwhile; ?>
<?php get_footer(); ?>