Support Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.






Pages: [1]
Author Topic: UWPQS to remember search form values on submit
yulia1872
Newbie
Posts: 4
Permalink
Post UWPQS to remember search form values on submit
on: November 3, 2016, 02:19
Quote

Hi there,

Thank you for the great plugin.

How do I make the search form remember what values I searched for on submit? For example, I have a dropdown for countries, how do I make sure that that's selected once I hit submit?

Thanks,
Yulia.

tck30
Administrator
Posts: 529
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 3, 2016, 03:28
Quote

Are you using Ajax result template? If so, it cannot, because ajax is stateless implementation.
If you using the default result template, then the plugin already support that.

New Add-On Plugins for Ultimate WP Query Search Filter has been released! Check it out now.

Buy Me A Beer! Thanks

yulia1872
Newbie
Posts: 4
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 7, 2016, 16:48
Quote

I am using a custom results template - only the the checkboxes stay checked on submit, the dropdown gets reset.

See here: http://tundraswan.com/search-photos/

tck30
Administrator
Posts: 529
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 8, 2016, 05:24
Quote

I see the dropdown field has been modified. Show me your customization codes so that I can see what's wrong with it.

New Add-On Plugins for Ultimate WP Query Search Filter has been released! Check it out now.

Buy Me A Beer! Thanks

yulia1872
Newbie
Posts: 4
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 8, 2016, 21:55
Quote

Hi there,

I took this code from a snipped you provided for someone else on this forum:


add_filter('uwpqsf_tax_field_dropdown','add_post_Cgg','',12);
function add_post_Cgg($html ,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$opt,$c,$defaultclass,$formid,$divclass){
$eid = explode(",", $exc);
		$args = array('hide_empty'=>$hide,'exclude'=>$eid );	
		$taxoargs = apply_filters('uwpqsf_taxonomy_arg',$args,$taxname,$formid);
        	$terms = get_terms($taxname,$taxoargs); $count = count($terms);
 
			$html = '';
			$html  .= '<div class="'.$defaultclass.' '.$divclass.' tax-select-'.$c.'"><span class="taxolabel-'.$c.'">'.$taxlabel.'</span>';
			$html .= '<input  type="hidden" name="taxo['.$c.'][name]" value="'.$taxname.'">';
			$html .= '<input  type="hidden" name="taxo['.$c.'][opt]" value="'.$opt.'">';
			$html .=  '<select id="tdp-'.$c.'" name="taxo['.$c.'][term]">'; 
			if(!empty($taxall)){
				$html .= '<option selected value="uwpqsftaxoall">'.$taxall.'</option>';
			}
					
						foreach ( $terms as $term ) {	
						$term_obj = get_term( $term->term_id, $taxname );
					$html .= '<option value="'.$term->slug.'">'.$term->name.' ('.$term_obj->count.')</option>';}
					
			$html .= '</select>';
			$html .= '</div>';return $html;

	
}

Thank you!

tck30
Administrator
Posts: 529
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 9, 2016, 14:05
Quote

in the foreach statement, you just need to add a line

$selected = (isset($_GET['taxo'][$c]['term']) && $_GET['taxo'][$c]['term'] == $term->slug) ? 'selected="selected"' : '';

eg:

foreach ( $terms as $term ) {	
		$term_obj = get_term( $term->term_id, $taxname );
               $selected = (isset($_GET['taxo'][$c]['term']) && $_GET['taxo'][$c]['term'] == $term->slug) ? 'selected="selected"' : '';
        	$html .= '<option value="'.$term->slug.'" '.$selected.'>'.$term->name.' ('.$term_obj->count.')</option>';
}

New Add-On Plugins for Ultimate WP Query Search Filter has been released! Check it out now.

Buy Me A Beer! Thanks

yulia1872
Newbie
Posts: 4
Permalink
Post Re: UWPQS to remember search form values on submit
on: November 9, 2016, 17:43
Quote

Wonderful, thank you so much for your help!

Pages: [1]