Support

Account

Home Forums Add-ons Flexible Content Field Reverse query a repeater field within flexible content?

Helping

Reverse query a repeater field within flexible content?

  • Based on this: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/#examples

    I am trying to extract a list of posts using the information within a repeater field that is nested in a flexible content, and I have butchered the code so much at this point but I am getting nowhere, so I am hoping someone can guide me in the correct direction.

    The name of my Flexible content is “workshop_date”, the name of the repeater is “date_and_time” and the sub field I want to reverse query from is “date”.

    Again, any help or direction is much much much appreciated!!

  • I actually solved this! I didn’t do it the way I thought it would be, but I got it to work the way I needed it to work.

    function workshop_dates( $where ) {
    	$where = str_replace("meta_key = 'workshop_details_%", "meta_key LIKE 'workshop_details_%", $where);
    	return $where;
    }
    add_filter('posts_where', 'workshop_dates');
    
    // vars
    $date_now = date('Y-m-d H:i:s');
    
    // args
    $args = array(
        'post_type' => 'page',
        //'posts_per_page' => 2,
        'meta_query'    => array(
    
            array(
                'key'		=> 'workshop_details',
                'compare'	=> '>',
                'value'		=> 0
            )
        )
    );

    I basically pulled all of the fields, and once I had them, I displayed the nested repeater fields.

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

The topic ‘Reverse query a repeater field within flexible content?’ is closed to new replies.