My widget displays all the articles that have been included in the portfolio. I need to create a navbar on which I would insert buttons that will filter based on the selected category.
This is my code:
<div class="row portfolio-group">
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC', //ASC crescente
'posts_per_page' => '5',//NUM post visualizzati
'meta_query' => array(
array(
'key' => 'in_portfolio',
'value' => '1'
),
),
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' ); ?>
<div class="blog-card">
<div class="meta">
<div class="photo" style="background-image: url(<?php echo $url ?>)"></div>
<ul class="details">
<li class="author"><a href="#">Name Surname</a></li>
</ul>
</div>
<div class="description">
<h1><?php the_title(); ?></h1>
<h2><?php echo get_post_meta(get_the_ID(), 'tipologia', TRUE);?></h2>
<p><?php the_excerpt(); ?></p>
<p class="read-more">
<a href="<?php the_permalink(); ?>">Leggi tutto</a>
</p>
</div>
</div>
<?php
echo $args['after_widget'];
}
}
?>
<!-- #content --></div>
This is the code I use to extract the type of article created as a custom field which will then be used to filter the results:
<h2><?php echo get_post_meta(get_the_ID(), 'tipologia', TRUE);?></h2>