Viewing File: /home/cienp/public_html/inct-inovamed/wp-content/themes/inovamed/template-eventos.php

<?php /* Template Name: Eventos */ ?>

<?php get_header(); ?>
<?php include 'menu.php'; ?>
<section class="splash splashPesquisadores">
	<div class="wrapper grid">
		<h1 class="title"><?php echo get_field('titulopadrao'); ?></h1>
		<p class="subtitle smallWrapper"><?php echo get_field('introducao'); ?></p>
	</div>
</section>

<section class="eventos">
	<ul class="wrapper" id="ultimosEventos">
		<?php 
		$new_query = new WP_Query( array(
		    'post_type'      => 'eventos',
		    'orderby'        => 'menu_order',
			'status'         => 'published',
			'orderby'		 => 'post_date', 
			'order'          => 'DESC',
			'posts_per_page' => 3,
		) );

		while ( $new_query->have_posts() ) : $new_query->the_post();  ?>
		
		 	<li class="animate">
				<?php if (get_field('url_externa')){ ?>
					<a class="grid" href="<?php echo get_field('url_externa'); ?>">
				<?php }else{ ?>
					<a class="grid" href="<?php echo get_permalink(); ?>">
				<?php } ?>
		 			<div class="texto">	
		 				<?php 

							$today = date('Ymd');
							$date_string = get_field('data_de_fim');
							$date_string = str_replace('-', '', $date_string);
							
							if ($today < $date_string) {
							    $status = "vaiRolar";
							}else{
								$status = "jaRolou";
							}

							$inicio = strtotime( get_field( 'data_de_inicio' ) );
							$inicio = date( 'd', $inicio );

							$fim    =  strtotime( get_field( 'data_de_fim' ) );
							$fim    = date( 'd', $fim );
							
							$mesFim =  strtotime( get_field( 'data_de_fim' ) );
							$mesFim = date("m", $mesFim);

							$locale = 'pt_BR';
							$dateFormatter = new IntlDateFormatter(
							    $locale,
							    IntlDateFormatter::LONG, // date type
							    IntlDateFormatter::NONE  // time type
							);
							$dateFormatter->setPattern('LLLL'); // full month name with NO DECLENSION ;-)
							$mesFim = $dateFormatter->format(DateTime::createFromFormat('n', (string)$mesFim));
						?>
						<?php if (get_field('data_de_inicio') && get_field('data_de_fim')){ ?>
							<span class="data <?php echo $status; ?>"><b><?php echo $inicio; ?></b> a <b><?php echo $fim; ?></b> de <span><?php echo $mesFim; ?></span></span>
						<?php } ?>
		 				<?php if (!get_field('data_de_inicio') && get_field('data_de_fim')){ ?>
							<span class="data <?php echo $status; ?>"><b><?php echo $fim; ?></b> de <span><?php echo $mesFim; ?></span></span>
						<?php } ?>
		 				<h2><?php echo the_title(); ?></h2>
						<?php echo the_excerpt(); ?>
						<span class="infos">Mais informações ></span>
					</div>
			 		<div class="photo animate">
						<?php echo get_the_post_thumbnail( $page->ID, 'large' ); ?>
					</div>
					
				</a>
			</li>
		
		<?php endwhile;  
		wp_reset_postdata(); ?>
		
	</ul>
	<?php  $count = wp_count_posts( 'eventos' )->publish;
	if($count >  3) {
		echo '<div class="wrapper"><span class="carregaPosts carregaEventos botao">Carregar mais</span></div>';
	} ?>

</section>



<?php get_footer(); ?>



Back to Directory File Manager