Hi, thank you for your support.
For your questions:
1) yes
2) yes
3) yes
However, this code works!
<?php
$zone_articoli = get_field('zona_per_i_pacchetti');
$args = array(
'post_type'=>'pacchetto',
'meta_key'=>'zona_per_gli_articoli',
'meta_value'=>$zone_articoli
);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php endwhile; wp_reset_postdata();?>
A last question:
If i want use a multiple select for a field, how i can do it?
The field that i want use is ‘zona_per_gli_articoli’
Thank you so much for your help!
Hi, thank you for your response..
I tell you what you ask me..
My custom post type is ‘pacchetto’ and i have two group for each post type. One for the wordpress posts: and one for my custom post type:
I want a query with CPT’s posts ‘pacchetto’ in sigle.php where return the posts when fields ‘zona_per_gli articoli’ = ‘zona-per-i-pacchetti’
I use the follow code:
<?php
$zone_articoli = get_field('zona_per_i_pacchetti');
$args = array(
'post_type' => 'pacchetto',
'meta_query' => array(
'key' => 'zona_per_gli_articoli',
'value' => $zone_articoli
);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php endwhile; wp_reset_postdata();?>
This code return me all posts from CPT ‘pacchetto’ and not filtering with fields. I think because i am in single.php and there are a rules for each post type
In effect if i write
echo $zone_articoli
it return the effective value, but if i write
$zone_pacchetti = get_field('zona_per_gli_articoli');
echo $zone_pacchetti;
don’t work (no value).
This last code work in single-pacchetto.php
I think i must merge the location rules for make my query with my fields…
Thank you so much!