Created
February 16, 2018 15:17
-
-
Save 19h47/b72d3da289825dfe7ce7e3918bf5a463 to your computer and use it in GitHub Desktop.
WordPress navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; | |
$args = array( | |
'post_type' => 'post', | |
'posts_per_page' => 12, | |
'post_status' => 'publish', | |
'paged' => $paged, | |
); | |
$the_query = new WP_Query( $args ); | |
if ( $the_query->have_posts() ) : | |
while ( $the_query->have_posts() ) : | |
$the_query->the_post(); | |
$terms = wp_get_object_terms( get_the_ID(), 'category' ); | |
$iconCat = 'default'; | |
$maincat = false; | |
if( $terms ) { | |
$maincat = $terms[0]; | |
$iconCat = get_field('icon_cat', $maincat); | |
} | |
?> | |
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"> | |
<div class="push-border push-article"> | |
<div class="head-article"> | |
<div class="container-icon"> | |
<span class="icon <?php echo $iconCat; ?>"></span> | |
</div> | |
<div class="info-article"> | |
<?php if($terms[0]): ?> | |
<div class="category"> | |
<?php echo $terms[0]->name; ?> | |
</div> | |
<?php endif; ?> | |
<div class="date"> | |
<?php echo get_the_date('d/m/Y'); ?> | |
</div> | |
</div> | |
</div> | |
<div class="title"> | |
<?php echo truncated(get_the_title(), 60) ?> | |
</div> | |
<div class="intro"> | |
<?php echo truncated(get_the_excerpt(), 80); ?> | |
</div> | |
<a href="<?php echo get_the_permalink(); ?>" class="link-block"> | |
<p class="link-arrow"> | |
<span class="icon-arrow icon"></span> | |
Lire la suite | |
</p> | |
</a> | |
</div> | |
</div> | |
<?php endwhile ?> | |
<div class="col-xs-12"> | |
<?php | |
if ( function_exists( 'get_pagination' ) ) { | |
echo get_pagination( $the_query->max_num_pages, 12 ); | |
} | |
?> | |
</div> | |
<?php wp_reset_postdata(); ?> | |
<?php endif ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment