I trying query posts by custom fields following example from this page:
https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
I have an Custom Post type called “playlists”
I have a custom field (select options) called “categorias”
I have the selections options: Educação, Arte, Experimentação
I trying make a loop for display the results if the option selected is “Education”:
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'playlists',
'meta_key' => 'categorias',
'meta_value' => 'Educação'
);
// query
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<img src="<?php the_field('event_thumbnail'); ?>" />
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
But this not show anything
I don’t have the pro version.
what kind of field is categorias
A select field with multiple values stores those values as a serialized array in the database. To do a query on this type of field see section 3. Multiple custom field values (array based values) on this page https://www.advancedcustomfields.com/resources/query-posts-custom-fields/