I am trying to create a loop to show only the contents of a selection ! I’ve tried to do the query as it is on the site and it still fails !
They could help me?
Follow my code:
<?php
$args = array(
'post_type' => 'Professor',
'meta_key' => 'area_do_professor',
'meta_value' => 'Treinamento_Total'
);
$queryTreina = new WP_Query($args);
if ($queryTreina->have_posts()) : while ($queryTreina->have_posts()) : $queryTreina->the_post();
get_template_part('partials/content', 'professores');
endwhile;
endif;
?>
I generated my fields at ACF as follows Mandeira as shown in the picture!
I’m waiting , thank you!
Hi,
I think your main issue is that you’re not using the posttype slug for post_type.
Also unless you set posts_per_page it will default to your setting in wp admin.
<?php
$args = array(
'post_type' => 'professor',
'meta_query' => array(
array(
'key' => 'area_do_professor',
'value' => 'Treinamento_Total',
'compare' => '='
)
),
'posts_per_page' => -1
);
$queryTreina = new WP_Query($args);
if ($queryTreina->have_posts()) : while ($queryTreina->have_posts()) : $queryTreina->the_post();
the_title(); //to make sure it works
get_template_part('partials/content', 'professores');
endwhile;
endif;
?>