/**
* recent post, sticly posts removed from the list
*/
function recent_post_side() {
global $post;
$sticky = get_option('sticky_posts');
if( !empty($sticky) ){ //if there is sticky post
$args=array(
'post_type' => 'post',
'post__not_in' => array($post->ID, $sticky[0]),
'posts_per_page'=> '2',
'order' => 'DESC',
'orderby' => 'date',
'ignore_sticky_posts' => 1
);
}else{
$args=array(
'post_type' => 'post',
'post__not_in' => array($post->ID),
'posts_per_page'=> '2',
'order' => 'DESC',
'orderby' => 'date',
'ignore_sticky_posts' => 1
);
};
$recent_posts = new WP_Query($args);
if( $recent_posts->have_posts() ) {
echo '<div class="row related_posts">';
echo '<h2 class="col-12 title">Les articles plus récents</h2>';
while ($recent_posts->have_posts()) : $recent_posts->the_post();
echo '<div class="col-md-6 col-lg-12">';
get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format());
echo '</div>';
endwhile;
echo '</div>';
}
wp_reset_query();
}