<?php
/*
Template Name: Actualite Page
*/
?>

<?php get_header(); ?>
 
        <div id="container">
            <div id="content">

            	<h1 id="centered-page-title"><?php the_title(); ?></h1>
 				
 				<div id="news">


 					<?php 

 					$the_featured_query = new WP_Query( 'post_type=post&meta_key=iwb_featured_article&meta_value=on&showposts=1' );

 					if( $the_featured_query->have_posts() ) : 
 						while ( $the_featured_query->have_posts() ) :
 							$the_featured_query->the_post(); 

 							//$news_item_text = get_post_meta( $the_featured_query->post->ID, 'excerpt', true );
 							//$news_item_text = get_the_excerpt();
	            			/*if ( strlen( $news_item_text ) == 0 ){
    							$news_item_text = substr( strip_tags( $the_featured_query->post->post_content ), 0, 450 );
    						}*/
    						

 					?>

		 					<div class="news-item featured-news-item">

		 						<div class="featured-news-text">
		 							<h3>À LA UNE: <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

		 							<div>
									<?php
									if ( !has_post_format( 'aside' ) ) {
										the_excerpt();
										
									}else{
										the_content();
									}
									?>
		 							</div>

									<?php
									if ( !has_post_format( 'aside' ) ) {
									?>
		 							<a href="<?php the_permalink(); ?>" class="featured-news-read-more">En Savoir +</a>
									<?php
									}
									?>
		 						</div>
		 						<div class="featured-news-img">
		 							<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
		 						</div>

		 						<div class="clear"></div>
		 					</div> <!-- .featured-news-item -->

 					<?php

 						endwhile;
 					endif;

 					// Reseting post data
	            	wp_reset_postdata();

 					?>

	            	<?php 

	            	$the_query = new WP_Query( 'post_type=post' );

	            	if( $the_query->have_posts() ) : 
	            		while ( $the_query->have_posts() ) :
	            			$the_query->the_post(); 

	            			//$news_item_text = get_post_meta( $the_query->post->ID, 'excerpt', true );

	            			//$news_item_text = get_the_excerpt();

	            			//if ( $news_item_text == '' ){
    						//	$news_item_text = substr( strip_tags( $the_query->post->post_content ), 0, 250 );
    						//}

	            			?>

	            			<div class="news-item">

	            				<div class="news-item-img">
	            					<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" ><?php the_post_thumbnail(); ?></a>
	            				</div>

	            				<div class="news-item-text">

	            					<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

	            					<div>

	            						<?php
								if ( !has_post_format( 'aside' ) ) {
									the_excerpt();
								}else{
									the_content();
									
								}
								?>

	            					</div>

							<?php
							if ( !has_post_format( 'aside' ) ) {
							?>
	            						<a href="<?php the_permalink(); ?>"  class="news-read-more">En Savoir +</a>
							<?php
							}
							?>
		    				</div>

	            				<div class="clear"></div>

	            			</div><!-- .news-item -->

	            			<?php

	            		endwhile;

	            		?>

	            		<div class="news-navigation">
	            			<?php previous_posts_link('Previous'); ?>
	            			<?php next_posts_link('Next'); ?>
	            		</div>

	            		<?php
	            	else:
	            		_e('No news yet.');
	            	endif;

	            	// Reseting post data
	            	wp_reset_postdata();
	            	?>

            	</div> <!-- #news -->
 
            </div><!-- #content -->
        </div><!-- #container -->
 
<?php get_sidebar(); ?>
<?php get_footer(); ?>
