Hi all, I have searched and i can’t seem to get this working. Not sure if I am doing something wrong or missing something. Any help would be greatly appreciated.
I have a field group called Swatch Detail with in that I have a field called Stock Status with a few options like In Stock, Backordered, Out Of Stock
If I am only trying to get info to display from In Stock statuses how can I do that?
I am trying this but it’s not working…
<?php
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'swatch detail',
'meta_key' => 'stock_status',
'meta_value' => 'In Stock'
));
if($posts)
{
echo '<ul>';
foreach($posts as $post)
{
echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></li>';
}
echo '</ul>';
}
?>
Thank you!!
I am looking for the same, a research on a logical in a repeated … i tried hard but …
Anyone ?
Hi,
Hmm… the code you are using is correct for a simple text based field type. If you are using a complex field i.e. checkbox, then the code will be a little different.
Here is an example in the documentation that explains this: http://www.advancedcustomfields.com/resources/how-to-query-posts-filtered-by-custom-field-values/