i need to create a navbar filter that filter by my custom field in wordpress


this is my widget that displays all the articles that have been included in the portfolio.
I need to create a navbar on which I should insert buttons that will filter based on the selected category.

this is my code:

    <div class="row portfolio-group">
  $args = array(
    'post_type' => 'post',
    'orderby' => 'date',
    'order'   => 'DESC', //ASC crescente
    'posts_per_page' => '5',//NUM post visualizzati
    'meta_query' => array(
        'key' => 'in_portfolio',
        'value' => '1'

  $post_query = new WP_Query($args);
  if($post_query->have_posts() ) {
    while($post_query->have_posts() ) {


<?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>
<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>

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>


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/i-need-to-create-a-navbar-filter-that-filter-by-my-custom-field-in-wordpress/">

i need to create a navbar filter that filter by my custom field in wordpress</a>
, , , , King Greg 6 months 0 Answers 50 views 0

Leave an answer