<?php
	$categories = get_the_category();
	$idPost = get_the_ID();
 	$obra_referenciada = get_field( "obra_referenciada", $idPost);
	$category_list = '';

	if($categories) {
		foreach ($categories as $category) {
			if( $category_list != '' ) {
				$category_list .= ', ';
			}
			$category_list .= $category->name;
		}
	}

	global $more, $image_size;
	$more = 0;

	if( !$image_size ) {
		$image_size = '';
	}

	$post_class = 'blog-posts';

	/* Add sticky class to featured posts (added for shortcode support) */

	if( is_sticky() ) {
		$post_class .= ' sticky';
	}

	/* Add no avatar class */

	if( !get_option('show_avatars') ) {
		$post_class .= ' no-avatar';
	}
?>


<?php

	if($category_list == "testimonios"){

		$url = get_site_url().$obra_referenciada;

		$postReferenciadoid = url_to_postid( $url );

		$industria = get_field( "actividad", $postReferenciadoid);
		$pais = 	get_field( "pais", $postReferenciadoid);



	}


?>


<article   id="post-<?php the_ID(); ?>" <?php post_class($post_class); ?>  data-type="testimonio" data-industria="<?php echo $industria ?>"   data-pais="<?php echo $pais ?>">
	<header>
		<?php if ( has_post_thumbnail() && get_the_post_thumbnail() ): ?>
			<a class="blog-post-image" href="<?php

			if($category_list == 'testimonios'){
			 echo  get_site_url().$obra_referenciada;
			} else{

			echo	get_the_permalink();

			}

			 ?>">
				<?php the_post_thumbnail($image_size); ?>
			</a>

					<div class="blog-post-author">
				<?php if( get_option('show_avatars') ): ?>
					<div class="blog-post-author-image">
						<?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?>
					</div>
				<?php endif; ?>
				<div class="blog-post-author-details">
					<?php _e( 'By', 'dropout' ); ?> <span class="author-name"><?php the_author(); ?></span>
					<?php _e( 'on', 'dropout' ); ?> <time datetime="2014-09-10 17:00"><?php echo get_the_date('M jS, Y'); ?></time>
				</div>
			</div>
		<?php endif; ?>
		<?php if( is_sticky() ): ?>
			<div class="sticky-header"><?php _e( 'Featured Post', 'dropout' ); ?></div>
		<?php endif; ?>
		<a href="<?php

			if($category_list == 'testimonios'){
			 echo  get_site_url().$obra_referenciada;
			} else{

			   echo get_the_permalink();

			}

			 ?>"><h2 class="blog-post-title"><?php the_title(); ?></h2></a>
	</header>
	<div class="blog-post-content">
		<?php if(get_option("rss_use_excerpt") == "0"): ?>
			<?php the_content(); ?>
		<?php else: ?>
			<?php the_excerpt(); ?>
		<?php endif; ?>
	</div>
	<footer>
		<a href="<?php
		if($category_list == "testimonios"){



			 echo  get_site_url().$obra_referenciada;

		}else{
			echo get_the_permalink();
		}




		?>" class="more"><?php _e( 'Read more', 'dropout' ); ?></a>
		<a href="<?php echo get_the_permalink(); ?>#comments" class="blog-post-comments-link">
			<i class="fa fa-comment-o"></i>
			<?php comments_number( __('0 comments', 'dropout'), __('1 comment', 'dropout'), __('% comments', 'dropout') ); ?>
			<i class="fa fa-share"></i>
		</a>
	</footer>
</article>

<script>

jQuery("article").attr("data-type","testimonio").each(function(){


	var este = jQuery(this);

	var claseIndustria = este.attr("data-industria");
	var clasePais = este.attr("data-pais");

		jQuery(this).parent("div").addClass("divContendorArticle");

	jQuery(this).parent("div").addClass(claseIndustria);

	jQuery(this).parent("div").addClass(clasePais);


});






</script>
