Hi, I need help with a query on a subfield I have the code below that I´m using from
query-posts-custom-fields
but I have always the same result, no matter what I put on the ‘value’ of my query, What I want to do is a list of product post that have a repeaterfield name galeria and a subfield name vaso and that vaso subfield has the value Alma Forest, but I don’t know what to do to achieve this. I really appreciate any help.
// filter
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'galeria_$", "meta_key LIKE 'galeria_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// vars
$vaso = 'Alma Forest';
// args
$args = array(
'numberposts' => -1,
'post_type' => 'event',
'meta_query' => array(
array(
'key' => 'galeria_$_vaso',
'compare' => '=',
'value' => 'Alma Forest',
)
)
);
// 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(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post().
Are you changing the value in the meta query or the value for the variable?
How do I create a subquery in SQL?