[closed] Search posts with custom advanced search form (3 posts)

  1. TWvM
    Posted 2 years ago #

    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:


    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'); ?>/">
            <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" />
        		$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>';
        		print $checkboxes;
            <input type="submit" id="searchsubmit" value="search" />

    Can someone point me in the right direction? What am I missing? Or is there an easier way to do this?

  2. Alexandre BOURLIER
    Posted 2 years ago #


    I am having a similar need.
    Have you, by any chance, find a way to implement what you wanted?

    Many thanks!
    All the best!

  3. esmi
    Forum Moderator
    Posted 2 years ago #

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else's topic.

    I am now closing this 2 month old topic as it references an older version of WordPress.

Topic Closed

This topic has been closed to new replies.

About this Topic