This repository has been archived on 2024-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
qdouze2-wordpress-theme/components/featured.php

40 lines
1 KiB
PHP
Raw Normal View History

2022-12-17 19:46:29 +01:00
<div id="featured-articles">
<?php
2022-12-18 15:17:25 +01:00
query_posts(array(
2022-12-17 19:46:29 +01:00
'post_type' => 'post',
'tax_query' => array(
array(
2022-12-18 15:17:25 +01:00
'taxonomy' => 'niveau',
'terms' => 'featured',
2022-12-17 19:46:29 +01:00
'field' => 'slug',
)
),
'orderby' => 'date',
2022-12-18 15:17:25 +01:00
'posts_per_page' => '3',
'order' => 'DESC'
2022-12-17 19:46:29 +01:00
));
2022-12-18 15:17:25 +01:00
2022-12-17 19:46:29 +01:00
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
2022-12-18 15:17:25 +01:00
<article class="preview-featured">
<a href="<?php the_permalink(); ?>" class="preview-link">
<div class="preview-item" style="background-image:url('<?php echo get_the_post_thumbnail_url(); ?>');">
<div class="preview-overlay">
<div class="preview-categories">
<?php $category = get_the_category();
echo"<span class='badge bg-primary'>" . $category[0]->cat_name . "</span>"; ?>
</div>
<h2 class="preview-title"><?php the_title();/*3*/ ?></h2>
</div>
</div>
</a>
</article>
2022-12-17 19:46:29 +01:00
<?php endwhile; ?> <?php wp_reset_query(); /*4*/ ?>
</div>
2022-12-18 15:17:25 +01:00