Skip Navigation

[Closed] Parametric search – Hide the results

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 4 replies, has 3 voices.

Last updated by Adriano 9 years, 7 months ago.

Assisted by: Adriano.

Author
Posts
#245052

Hi,
I have settled a parametric Search view in : hidden link
I've a problem : all the list of result of the query on the post category stay always displayed before making any search.
I need the result displayed only after making the search, not always.
Thanks fir the help !
Regards

#245183

Hi michelG,

The URL you mentioned above is not valid, please check it.
I assume you are going to display results only when user click the search button of Views,

Please try Views filter hook wpv_filter_query like this, add codes in your theme/functions.php:

add_filter( 'wpv_filter_query', 'hide_results_func', 10, 3 );

function hide_results_func( $query, $settings, $views_id ) {
    if($views_id == 123){ // 123 need be replaced with your views ID
		if(!isset($_REQUEST['wpv_filter_submit'])){
			$query['post__in'] = array(-2);;
		}
	}
	
    return $query;
}

Please replace 123 with your view's ID

#245205

Hi Luoy !

The right URL is : hidden link

Many thanks for your answer, the goal is to hide the results before client search, you're right !

As I'm not a programming pro I've made what I've understood

1 - I've added this to functions.php of the theme site:

add_filter( 'wpv_filter_query', 'hide_results_func', 10, 3 );

function hide_results_func( $query, $settings, $views_id ) {
if($views_id == 2675){ // 1675 is my views ID
if(!isset($_REQUEST['wpv_filter_submit'])){
$query['post__in'] = array(-2);;
}
}

return $query;
}

A message is returned :
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /pathto/asso-hyeres.org/wp-content/themes/inovado_theme/functions.php on line 432

What I've made wrong ?

Just a last info : this site runs under a WordPress multisite setting.

Please explain to me precisely, step by step qhat have to be done.
Many thanks by advance !

#245213

Hi !

I've found a part of the problem : I've made the copy from the email and on it the code was badly formated !

I copy/paste the code from here and now the error message disappeared !
Now the results are hidden, but the query no more works !

An idea ?

#245271

Luo is not available to help you with this issue, I will.

I have another idea instead of using custom PHP code, but Views features. Please take a look in the "Adding Just the Search Form to a Page" section of the page: https://toolset.com/documentation/user-guides/front-page-filters/

There you will learn how to display the Views form and results in different pages.

Please let me know if you are satisfied with my answer and if I can help you with any other related question.

The topic ‘[Closed] Parametric search – Hide the results’ is closed to new replies.