Search posts with custom advanced search form
-
I’m trying to create a custom advanced search form for my posts. I have been able to create the looks of the search form:
https://i1164.photobucket.com/albums/q575/Tako_Wako/Schermafbeelding2014-03-17om225800.png
As you can see, I want a search form with a search field, dropdown menus and checkboxes. But right now it’s not working correctly. I’m new to WordPress and PHP so all I’ve got I got from the internet.
<?php $provincie = array( 'hierarchical' => 1, 'parent' => get_cat_id('Provincie'), 'show_option_none' => ('Alle Provincies'), 'hide_empty' => 0 , 'order' => 'DESC' ); ?> <?php $jaar = array( 'hierarchical' => 1, 'parent' => get_cat_id('Jaar'), 'show_option_none' => ('Alle Jaren'), 'hide_empty' => 0 , 'order' => 'ASC' ); ?> <?php $dag = array( 'hierarchical' => 1, 'parent' => get_cat_id('Dag'), 'show_option_none' => ('Alle Dagen'), 'hide_empty' => 0 , 'order' => 'ASC' ); ?> <?php $activiteit = array( 'child_of' => 58, 'orderby' => 'ID', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1 ); ?> <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> <div> <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" placeholder="Zoekterm" /> <?php wp_dropdown_categories($provincie); ?> <?php wp_dropdown_categories($jaar); ?> <?php wp_dropdown_categories($dag); ?> <input type="hidden" id="my_search" name="my_search" value="c_search" /> <div><h3>Activiteit</h3></div> <div> <?php $categories = get_categories( $activiteit ); $checkboxes = ''; foreach($categories as $categorie) : $checkboxes .='<input type="checkbox" name="tag[]" value="'.$categorie -> slug.'" id="categorie-'.$categorie->term_id.'" /><label for="categorie-'.$categorie->term_id.'">'.$categorie->name.'</label>'; endforeach; print $checkboxes; ?> </div> <input type="submit" id="searchsubmit" value="search" /> </div> </form>
Can someone point me in the right direction? What am I missing? Or is there an easier way to do this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Search posts with custom advanced search form’ is closed to new replies.