home.php 3.01 KB
Newer Older
agnez's avatar
agnez committed
1 2 3 4 5 6
<?php

add_action( 'beans_content_prepend_markup', 'gasap_latest_news' );
function gasap_latest_news() {
	$do_not_duplicate = array();?>
	<article id="snippet_latest_news" class="uk-article"><?php
agnez's avatar
agnez committed
7 8 9 10 11 12
			$latest_news = new WP_Query( array(
					'post_type' => 'post',
					'orderby' => 'post_date',
					'order' => 'DESC',		
					'posts_per_page' => 1
			));
agnez's avatar
agnez committed
13 14
			while ( $latest_news->have_posts() ) : $latest_news->the_post();
			$do_not_duplicate[] = get_the_ID();?>
agnez's avatar
agnez committed
15 16 17 18
				<div><?php	
				if ( has_post_thumbnail() ) { ?>
					<figure class="uk-overlay"><?php
						the_post_thumbnail( 'diaporama', array( 'alt' => '-' ) ); ?>
agnez's avatar
agnez committed
19 20 21
						<div class="uk-overlay-panel uk-overlay-background uk-text-center">
							<h3 class="uk-article-title"><?php the_title(); ?></h3>
						</div>
agnez's avatar
agnez committed
22 23 24 25 26
					</figure><?php
				} else{?>
					<h1 class="uk-article-title"><?php the_title(); ?></h1><?php
				} ?>			
					<div class="largeur1">					
agnez's avatar
agnez committed
27 28 29
						<div><?php the_content(); ?></div>
						<?php edit_post_link( esc_html__( 'Edit news', 'beans_gasap' ), '<span class="edit-link">', '</span>' ); ?>
					</div>
agnez's avatar
agnez committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43
				</div><?php
			endwhile;
			wp_reset_postdata(); ?>
	</article>

<section id="snippet_next_three_news">
<?php
$loop2 = new WP_Query( array(
		'post_type' => 'post',
		'orderby' => 'post_date',
		'order' => 'DESC',		
		'posts_per_page' => 3,
		'post__not_in' => $do_not_duplicate
));?>
agnez's avatar
agnez committed
44
	<div class="uk-grid uk-grid-small largeur1" data-uk-grid-margin><?php
agnez's avatar
agnez committed
45 46 47 48 49 50 51 52 53 54
		while ( $loop2->have_posts() ) : $loop2->the_post();
		$random_number = wp_rand( 1, 3 ); ?>
			<div class="uk-width-1 uk-width-small-1-2 uk-width-medium-1-3">
				<div>
					<figure class="uk-overlay">
						<?php	
						if ( has_post_thumbnail() ) { the_post_thumbnail( 'newsthumb', array( 'alt' => '-' ) ); } 
						else { echo '<img src="' . get_stylesheet_directory_uri() . '/assets/img/default_news_thumbnail.png" width="230" height="210" alt="-">'; }?>
						<a class="uk-position-cover" href="<?php echo get_the_permalink(); ?>"></a>
					</figure>
agnez's avatar
agnez committed
55
						<div class="postdate"><?php esc_html_e( 'Publié le ', 'beans_gasap' ); echo date_i18n( get_option( 'date_format' )); ?></div>					
agnez's avatar
agnez committed
56 57 58 59 60 61 62 63
						<h2 class="textegauche"><?php the_title(); ?></h2>
						<a class="uk-button uk-button-success" href="<?php echo get_the_permalink(); ?>"><?php esc_html_e( 'Discover', 'beans_gasap' ); ?></a>			
				</div>
			</div><?php
		endwhile;
		wp_reset_postdata(); ?>
	</div>
</section><?php
agnez's avatar
agnez committed
64 65 66

}

agnez's avatar
agnez committed
67 68
beans_remove_action( 'beans_loop_template' );

agnez's avatar
agnez committed
69

agnez's avatar
agnez committed
70 71
add_action( 'beans_content_after_markup', 'gasap_bottom' );
function gasap_bottom() {
agnez's avatar
agnez committed
72 73
	include (get_stylesheet_directory() . '/assets/template_parts/news_slider.php');	
	//include (get_stylesheet_directory() . '/assets/template_parts/latest_news.php');	
agnez's avatar
agnez committed
74 75
	//include (get_stylesheet_directory() . '/assets/template_parts/event_calendar.php');
	include (get_stylesheet_directory() . '/assets/template_parts/contact_calendar.php');
agnez's avatar
agnez committed
76 77 78 79 80 81
	include (get_stylesheet_directory() . '/assets/template_parts/footer.php');
}

// Load document which is always needed at the bottom of template files.
beans_load_document();