bluvertigo
9/29/2014 - 10:59 AM

Shortcode - ricerca personalizzata / custom search

Shortcode - ricerca personalizzata / custom search

function wpbsearchform( $atts, $form ) {

	$atts = shortcode_atts(
			array(
				'search_page' => 'cerca',
				'search_form_page' => 'modulo-ricerca',
				'tipo1' => 'vendita',
				'tipo2' => 'affitto'
			), $atts);

    $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . $atts['search_page'] . '/' . '" >
    <div><label class="screen-reader-text" for="search">' . 'Cerca:' . '</label>
    <input type="text" value="" name="search" id="search" /><br/>
    <div class="twocol-one"><label class="screen-reader-text" for="da_prezzo">' . 'Prezzo minimo:' . '</label>
    <input type="text" value="" name="da_prezzo" id="da_prezzo" /></div>
    <div class="twocol-one last"><label class="screen-reader-text" for="a_prezzo">' . 'Prezzo massimo:' . '</label>
    <input type="text" value="" name="a_prezzo" id="a_prezzo" /></div>
    <div class="twocol-one"><label class="screen-reader-text" for="da_mq">' . 'Da mq:' . '</label>
    <input type="text" value="" name="da_mq" id="da_mq" /></div>
    <div class="twocol-one last"><label class="screen-reader-text" for="a_mq">' . 'A mq:' . '</label>
    <input type="text" value="" name="a_mq" id="a_mq" /></div>
    <label class="screen-reader-text" for="tipologia">' . 'Tipologia:' . '</label>
    <select id="tipologia" name="tipologia" >
  		<option value="'. $atts['tipo1']  .'">'. ucfirst($atts['tipo1'])  .'</option>
  		<option value="'. $atts['tipo2']  .'">'. ucfirst($atts['tipo2'])  .'</option>
	</select><br/>
    <input type="hidden" value="' . $atts['search_form_page'] . '" name="search_form_page" id="search_form_page" />
    <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
    </div>
    </form>';
    return $form;
}
add_shortcode('custom_search_form', 'wpbsearchform');