<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package Loyt
 */

get_header();?>
<?php while ( have_posts() ) : the_post(); ?>
	<section class="banner-paginas container">
		<ul class="body-list"><?php
			$images = types_render_field("banner-page", array("raw"=>"true", "separator"=>";"));
			$banners = explode(";", $images);
			$cont = 0;
			foreach( $banners as $banner ):
				if ($cont==0) {?>
			<li class="active"><?php 
			} else {?>
			<li><?php
			} ?>
			<figure>
				<img src="<?php echo $banner; ?>"alt="Loyt" class="img-responsive" />
			</figure>
		</li><?php
		$cont++;
		endforeach;?>
	</ul>
</section>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<div class="container">
	<div class="quienes">
		<section class="col-md-12">
			<h1>Contendores mar&iacute;timos </h1>
		</section>
		<?php  
		$tiposContenedores = get_terms( 'tipo-contenedor', array(
			'orderby'    => 'id',
			'hide_empty' => 1
			) );
		foreach ( $tiposContenedores as $tipo ) 
		{
			$name = $tipo->name; ?>
			<section class="col-md-12">
				<h2><?php echo $name; ?></h2><?php
				$container_args = array(
					'post_type' => 'contenedor',
					'orderby' => 'title',
					'order' => 'ASC',
					'tax_query' => array(
						array(
							'taxonomy' => 'tipo-contenedor',
							'field' => 'slug',
							'terms' => $tipo->slug,
							'include_children' => false
							)
						)
					);              
				$containers = new WP_Query( $container_args );  
				while ($containers->have_posts())
				{
					$containers->the_post();?>
					<section class="col-md-12 objcont">
						<section class="col-md-8">
							<h4><?php echo the_title(); ?></h4>
							<?php the_content(); ?>
						</section>
						<section class="col-md-4">
							<img src="<?php echo types_render_field('contenedor-image', array('output'=>'raw')); ?>" class="logoC"/>
						</section>
					</section><?php
				} ?>
			</section>
			<div class="clearfix"></div> <?php
		}
		?>
	</div>
</div>

<?php  wp_reset_postdata(); ?>
<?php get_footer(); ?>