Support

Account

Home Forums Front-end Issues Filtering through multiselect options in a repeater field

Unread

Filtering through multiselect options in a repeater field

  • Hi, I’m integrating a form of $_POST method with ajax filtering, to filter through repeater filed in all posts. so i’m not filtering posts (always all posts are displayed), just filtering inside each post.

    the repeater field contain two sub fields – multiselect and Wysiwyg Editor.
    Now, according to what the user selected in the front-end form, if it’s equal to a post multiselect values, it should display the Wysiwyg Editor field of the matching multiselect.

    I have this working without multiselect. but with the multiselect, i can’t get a conditional to be ALL selected filters values, to be the exact match of ALL multiselect values.
    So the result i get, as it is in a foreach loop, is multiple Wysiwyg Editor fields.

    I tried a lot of things, this is an example code of one of them:
    (‘cond_options’ – multiselect
    ‘description’ – Wysiwyg Editor’
    ‘ weather/sky/night’ – filters values)

    
    if ( have_rows('cond-repeater') ):
       while (have_rows('cond-repeater') ) : the_row();
    
            $select_options = get_sub_field('cond_options');
            $selectdesc = get_sub_field('description');
    
                if( $select_options ):
                   foreach( $select_options as $select ):
                        if( isset( $_POST['weather'] ) && $_POST['weather'] && isset( $_POST['sky'] ) && $_POST['sky'] && isset( $_POST['night'] ) && $_POST['night'] == $select  ){
                            echo $selectdesc;
                        }  
                echo $select; //just to see the output of selected options
                     endforeach; 
    
                endif; 
    
        endwhile;
    endif; 
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.