• I want to search the custom field values display in my page, and the results want to be displayed in the same page itself.
    My page div for displaying this custom field value are:

                    <div class="opening-form" id="opening-form">
                        <?php if( have_rows('account_opening_forms_section') ):                                     
                              while( have_rows('account_opening_forms_section') ): the_row();   
                            ?>
                        <h5><?php echo the_sub_field("main_heading"); ?></h5>
                        <div class="opening-form-listing">
                            <ul class="list-unstyled mb-0">
                                <?php if( have_rows('account_opening_forms') ):                                     
                                  while( have_rows('account_opening_forms') ): the_row();   
                                ?>
                                    <li>
                                        <div class="d-flex justify-content-between align-items-center w-100">
                                            <h4><?php echo the_sub_field("title"); ?></h4>
                                            <a href="<?php echo the_sub_field("download_link"); ?>" target="_blank" class="icon-download"></a>
                                        </div>
                                    </li>
                                <?php endwhile; ?>
                                <?php endif; ?>
                            </ul>
                        </div>
                        <?php endwhile; ?>
                        <?php endif; ?>
                    </div>

    But how can i search this values
    my search form is

    <form id="search-form" method="POST">                            <div class="search-form">                                <input type="text" class="search-box form-control" placeholder="Search by form name" name="s" value="<?php echo get_search_query(); ?>">                                <a href="javascript:void(0);" class="icon-search" id="formSearch"></a>                            </div>                        </form>
    
    



    • This topic was modified 11 months, 1 week ago by manjushakv.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The solution depends on how and where the repeater field values are stored in the DB. I’ll assume the data is at least within your WP DB. You can then use the global $wpdb connection object to make custom SQL queries. For example, by using the get_results() method.

    I’m guessing repeater field values are saved as a serialized array. If so, you will probably want to use a LIKE query with wildcards % to find a search term within the serialized array along with other pertinent qualifications such as the table name and column name to search within.

    get_results() will return any data matching your query, but using your have_rows() probably will not work with it. You can check if anything was found at all with empty(). If results were found, you can use foreach to loop through each of the results.

Viewing 1 replies (of 1 total)
  • The topic ‘searching custom field values with repeater field’ is closed to new replies.