WordPress.org

Forums

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

  1. TWvM
    Member
    Posted 1 year 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:

    http://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?

  2. Alexandre BOURLIER
    Member
    Posted 1 year ago #

    Hi,

    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 1 year 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