Home Forums Backend Issues (wp-admin) I need help with a subfields query


I need help with a subfields query

  • Hi, I need help with a query on a subfield I have the code below that I´m using from

    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(
    			'key'		=> 'galeria_$_vaso',
    			'compare'	=> '=',
    			'value'		=> 'Alma Forest',
    // query
    $the_query = new WP_Query( $args );
    <?php if( $the_query->have_posts() ): ?>
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	<?php endwhile; ?>
    <?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?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.