File: /datos/www/www.colombia.co/public_html/wp-content/themes/colombia2016/single-generic.php
<?php get_header(); ?>
<?php
while ( have_posts() ) : the_post();
$cat = get_the_category();
$cat_id = $cat[0]->term_id;
$images = get_option('taxonomy_image_plugin'); // get the taxonomy images array
if( array_key_exists( $cat_id, $images ) ) { // check if term has an image
$category_image = wp_get_attachment_image_src( $images[$cat_id], 'full' ); // if it does, echo that image
}
$category_color = get_term_meta( $cat_id , 'category_color', true );
$url_exploded = explode('/', parse_url(get_the_permalink(), PHP_URL_PATH));
$parent_category = 'category-'.$url_exploded[1];
// $os = array(2, 3, 19, 3446, 3447, 6, 106, 3461, 4390, 9);
// $imagen_articulo = "/wp-content/themes/colombia2016/img/bg-uncategorized2x.png";
// if(in_array($cat_id, $os)){
// $imagen_articulo = $category_image[0];
// }else{
// $imagen_articulo = get_term_meta($cat_id, 'imagen_articulo', true);
// }
?>
<?php if(($category_image)||($category_color)): ?>
<style>
<?php if($category_image): ?>
#post-header {
background-color:#9e1e71;
background-size: cover;
}
#category-header, #post-header {
text-align: center;
}
#category-header .cat-title {
padding: 22% 7% 0 7%;
text-transform: uppercase;
font: 260% 'Raleway', sans-serif !important;
width: 100%;
vertical-align: middle;
word-wrap: break-word;
}
<?php if($category_color): ?>
#post-content .post-content > p:first-of-type::first-letter {
color: <?php echo $category_color; ?>;
}
#post-content .post-content blockquote {
color: <?php echo $category_color; ?>;
}
#sidebar .related-posts .related-posts-title {
border-bottom-color: <?php echo $category_color; ?>;
}
<?php endif; ?>
<?php endif; ?>
</style>
<?php endif; ?>
<main role="main" class="l-flex <?php echo $parent_category ?>">
<div id="post-header">
<div class="l-container l-flex">
<div class="post-header-container">
<?php echo do_shortcode('[breadcrumb]'); ?>
<h1 class="post-title"><?php the_title(); ?></h1>
</div>
</div>
</div>
<div id="content-wrapper" class="l-container l-flex">
<section id="post-content">
<article <?php post_class('l-flex'); ?> id="post-<?php the_ID(); ?>">
<?php
$gallery = get_field('gallery_post');
$n = count($gallery);
if($gallery){
if($n > 1){
?>
<div id="post-slider" class="swiper-container">
<div class="swiper-wrapper">
<?php
foreach($gallery as $img){
$url = $img["image_gallery_post"]['url'];
$alt = $img["image_gallery_post"]['alt'];
$title = $img["image_gallery_post"]['title'];
$width = $img["image_gallery_post"]['width'];
$height = $img["image_gallery_post"]['height'];
if($width > $height){
?>
<div class="swiper-slide">
<figure class="slide">
<img class="slide-img" src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" title="<?php echo $title; ?>" />
</figure>
</div>
<?php
}
}
?>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-prev"><i class="icon-arrow-left"></i></div>
<div class="swiper-button-next"><i class="icon-arrow-right"></i></div>
</div>
<?php if(get_field('image_credit')): ?>
<div class="img-credits"><?php the_field('image_credit') ?></div>
<?php endif; ?>
<?php
}
else{
$url = $gallery[0]["image_gallery_post"]['url'];
$alt = $gallery[0]["image_gallery_post"]['alt'];
$title = $gallery[0]["image_gallery_post"]['title'];
$width = $gallery[0]["image_gallery_post"]['width'];
$height = $gallery[0]["image_gallery_post"]['height'];
if($width > $height){
?>
<figure class="post-img">
<img class="slide-img" src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" title="<?php echo $title; ?>" />
<?php if(get_field('image_credit')): ?>
<figcaption class="img-credits"><?php the_field('image_credit') ?></figcaption>
<?php endif; ?>
</figure>
<?php
}
}
}
elseif(has_post_thumbnail()){
if(has_post_video()){
?>
<figure class="post-img">
<?php the_post_thumbnail(); ?>
<?php if(get_field('image_credit')): ?>
<figcaption class="img-credits"><?php the_field('image_credit') ?></figcaption>
<?php endif; ?>
</figure>
<?php
}
else{
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->id), 'post-thumbnail');
if(($image[1] > 600) && ($image[1] > $image[2])):
?>
<figure class="post-img">
<?php the_post_thumbnail(); ?>
<?php if(get_field('image_credit')): ?>
<figcaption class="img-credits"><?php the_field('image_credit') ?></figcaption>
<?php endif; ?>
</figure>
<?php
endif;
}
}
?>
<div class="post-sharing">
<?php echo do_shortcode('[wp_social_sharing social_options="facebook, twitter,linkedin" facebook_text="" twitter_text="" linkedin_text="" icon_order="f,t,l"]'); ?>
</div>
<div class="post-data">
<!--<span class="post-author"><?php // the_author(); ?></span>-->
<span class="post-date"><?php the_date(); ?></span>
</div>
<div class="post-excerpt">
<?php echo get_the_excerpt(); ?>
</div>
<div class="post-content">
<?php the_content(); ?>
<!-- --><?php //if(function_exists("kk_star_ratings")) : echo kk_star_ratings(get_the_ID()); endif; ?>
</div>
<div class="post-tags">
<?php the_tags('', ''); ?>
</div>
<div class="post-sharing post-sharing-after">
<?php echo do_shortcode('[wp_social_sharing social_options="facebook, twitter,linkedin" facebook_text="" twitter_text="" linkedin_text="" icon_order="f,t,l"]'); ?>
</div>
</article>
<?php endwhile; ?>
</section>
<?php get_sidebar(); ?>
<section class="related-post-content">
<span class="title-related-post-content" ><?php _e('ArtÃculos recomendados', 'colombia'); ?></span>
<?php
if ( wp_is_mobile() ) :
echo do_shortcode('[DCRP_shortcode style="2" image="1" excerpt="1" date="0" postsperpage="10" columns="1"]');
else :
echo do_shortcode('[DCRP_shortcode style="1" image="1" excerpt="1" date="0" postsperpage="10" columns="1"]');
endif;
?>
</section>
</div>
</main>
<?php get_footer(); ?>