Passer la navigation

[Résolu] I want results view only displayed when clicking "submit"

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
I want results view only displayed when clicking "submit"
Solution:
It is possible to achieve it with some PHP code.

Here's an example of an implementation:

https://toolset.com/forums/topic/i-want-to-show-the-message-please-select-the-area-before-showing-the-selection/#post-1272533

/**
 * No initial results
 *
 * Don't show View results until a filter has been applied
 * 
 * Tests for custom field filters, taxonomy filters, or text searches
 */
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
   
    $target_views = array( 123 ); // Edit to add IDs of Views to add this to
 
    if ( in_array( $view_id, $target_views ) ) {
   
        // if there is a search term set
        if ( !isset( $query_results->query['meta_query'] ) && !isset( $query_results->query['tax_query'] ) && !isset( $query_results->query['s'] ) ) {
            $query_results->posts = array();
            $query_results->post_count = 0;
            $query_results->found_posts = 0;
        }
    }
   
    return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 10, 3 );

100% of people find this useful.

This support ticket is created Il y a 2 years, 2 months. 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 13:00 – 18:00 13:00 – 18:00 -

Fuseau horaire du supporter : America/Sao_Paulo (GMT-03:00)

Ce sujet contient 1 reply, a 2 voix.

Dernière mise à jour par Mateus Getulio Il y a 2 years, 2 months.

Assisté par: Mateus Getulio.

Auteur
Publications
#2686712

I want results view only displayed when clicking "submit"

lien caché

#2686732

Mateus Getulio
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Sao_Paulo (GMT-03:00)

Hello there,

It is possible to achieve it with some PHP code.

Can you please try to implement the solution described here? It aims the exact same behavior you need:

https://toolset.com/forums/topic/i-want-to-show-the-message-please-select-the-area-before-showing-the-selection/#post-1272533

The code in there is a nudge in the right direction, it may require some updates for it to work properly in your specific setup and environment.

Please give it a try and let us know the results.

Mateus