Skip Navigation

[Resolved] View Search listing all results

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by selmoK 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#872972

I am trying to block listing all results when no option is selected on the view search form.

On my filter editor, i have the code:

------------
<div class="formulario">

<div>
[wpv-control-postmeta field="wpcf-cidade-do-anuncio-empresa" type="select" default_label="Cidade" url_param="wpv-wpcf-cidade-do-anuncio-empresa"]
</div>

<div>
[wpv-control-postmeta field="wpcf-bairro-do-anuncio-empresa" type="select" default_label="Bairro" url_param="wpv-wpcf-bairro-do-anuncio-empresa"]
</div>

<div>
[wpv-control-postmeta field="wpcf-categoria-empresa" type="select" default_label="Categoria" url_param="wpv-wpcf-categoria-empresa"]
</div>
<div></div>
--------------

I need to check if the user selects an option on wpcf-cidade-do-anuncio-empresa. The other fields are optional. I can´t list all results. I am using this code on functions.php but it isn´t working:

$ids = array(830); //view code
if (in_array($view_id, $ids)){

if ( isset($_GET['wpcf-cidade-do-anuncio-empresa']) && $_GET['wpcf-cidade-do-anuncio-empresa'] != 'Cidade' )
// Cidade is the default value
{
} else {
$query_args['post__in'] = array(0);
}
}
return $query_args;

Can you help me, please?

#873770

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

Thank you for contacting our support forum.

Could you send the entire code section that you are using to remove the results.

Thanks,
Shane

#873797

Hi Shane,

Here is the code:

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

function default_blank_func( $query_args, $view_settings, $view_id ) {
$ids = array(830); //view code
if (in_array($view_id, $ids)){

if ( isset($_GET['wpcf-cidade-do-anuncio-empresa']) && $_GET['wpcf-cidade-do-anuncio-empresa'] != 'Cidade' )
// Cidade is the default value
{
} else {
$query_args['post__in'] = array(0);
}
}
return $query_args;
}

#877491

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

Thank you for the code.

Would you mind providing me with access to the site and a link to the page with this view so that I can help better with resolving this.

The private fields have been enabled for your next response.

Thanks,
Shane

#883232

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

Thank you for the credentials, however it seems that the password is incorrect.

Could you check on this and let me know.

Thanks,
Shane

#883633

Sorry, can i give you the password on a secure form?

#884750

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

I've enabled the private fields once more.

Thanks,
Shane

#892849

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

I must apologize for the delay in response.
I'm currently having a look at this for you now.

Thanks,
Shane

#892934

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Selmo,

I've managed to resolve this for you and it should now be working.

Thanks,
Shane

#893188

Shane,

It is working great!

Thank you very much,
Selmo