Skip Navigation

[Resolved] Search is not working

This support ticket is created 3 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by andyB-12 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1729597

Hey there I already successfully setup one of the needed searches.

Now I am trying to create another one, but somehow it is not showing any results. I added some filters but when clicking on them there is nothing to chose from...

hidden link

I also created two test posts and filled all custom fields, but somehow the search does not work.

EDIT:
I found the problem and now the results are showign, BUT when chosing any option in one of the dropdown menus, the other options disappear... Can you tell me how I can solve that?

#1729949

Hello, there is an option called "Only show available options for each input" that will show and hide filter options based on the other selected filters. It sounds like you want this turned OFF, but it is currently turned on. The location of this option depends on whether you're using the Block Editor or classic Views.

In the Block Editor, look for this option in the Custom Search configurations area when you select the top-level View block. You can use the Block Navigation menu at the top of the screen to easily select the top-level View block.

In the classic Views editor, you will find this option in the Custom Search settings panel when you select "Let me choose individual settings manually".

Let me know if I misunderstood what you're experiencing, or if you continue to have problems after setting the correct configuration.

#1730985

Hello Christian,

thanks a lot for your help. That solves one problem on the one hand, but opens another problem on the other hand. Now all dropdowns show all options, which is fine, except for the category dropdown, that should only show one spedific parent category and its child categories. Is that possible?

#1731453

There isn't a way to set that up in the View configurations in wp-admin but it's possible with some custom code. I have a snippet from another supporter that will allow you to whitelist specific terms to appear in the filter:

/**
 * Blacklist or whitelist terms in a taxonomy form field or View filter
 */
function tssupp_restrict_terms( $terms, $taxonomies, $args, $term_query ){

    // 1. pages where form (or search View) is inserted
    $pages = array( 118, 137 );

    // 2. which taxonomy (slug)
    $taxonomy = 'status';

    // 3. add terms to blacklist *OR* whitelist, not both
    $blacklist = array();
    $whitelist = array( 'archived', 'completed' );

    if ( is_page( $pages ) && $taxonomies[0] == $taxonomy ) {

        if ( !empty( $blacklist ) ) {

            foreach( $terms as $key => $term ){
     
                if ( in_array( $term->slug, $blacklist ) ) {
                    unset($terms[$key]);
                }
            }
        } elseif ( !empty( $whitelist ) ) {

            foreach( $terms as $key => $term ){
     
                if ( !in_array( $term->slug, $whitelist ) ) {
                    unset($terms[$key]);
                }
            }
        }
    }
     
    return $terms;
}
add_filter( 'get_terms', 'tssupp_restrict_terms', 10, 4 );

You can adjust the code in steps 1, 2, and 3 noted in the code comments. First, add a comma-separated list of numeric Page IDs where this custom search View is displayed. Second, change the slug of the taxonomy as needed to modify that taxonomy filter. Third, add a comma-separated list of term slugs to the whitelist or the blacklist (in your case, it sounds like you want to whitelist terms). You'll have to manually adjust this list as terms are added to the taxonomy, because this list is not dynamic.

That's the best solution I have available for achieving exactly what you've described. Let me know if you have questions about implementing this custom code in your child theme's functions.php file or in a new code snippet in Toolset > Settings > Custom Code.

#1732929

This sounds like a perfect solution, but I am not using the views on pages, but on archives. How can I get the IDs of those?

And I have another problem:

How can I achieve, that the grid is only for tablet and desktop and for mobile the results will show beneath each other? So 3 columns for tablet and desktop but 1 column for mobile?

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/responsive-grid-view-2/

#1732969

hidden link

hidden link

EDIT:
And the customer would like, that the first results show when clicking on the button and that no results show before clicking the button the first time.

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/show-no-results-until-filtered/

#1733167

I would also need advice on how to implement a map that shows marks on all addresses that are entered in the custom field of a specific custom post type. I already set up the custom post type and the custom fields and created three example posts with addresses and they are also showing up in the results, but I wasnt able to create a map that shows those addresses on the map.

hidden link
hidden link

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/show-marker-for-each-view-result-on-a-map/

#1733605

This sounds like a perfect solution, but I am not using the views on pages, but on archives. How can I get the IDs of those?
The conditional is_page() is there to prevent this code from firing all over the site. You would need a different conditional if the View will be displayed on archives, and the exact conditional is different depending on which archives you plan to include the View. I would need to know on which archives you plan to include the View to give you more guidance on that. If they are custom post type archives, let me know which post types, by slug. If they are taxonomy archives, let me know which taxonomy archives, by slug. If they are other archives, I need details on which archives.

I've split your new questions into separate tickets. Let's focus on the filter options in this ticket to keep the forum organized by issue. Thanks!

#1737353

We agreed to use the setting like in the beginning, as it wont be likely to be the case that some filter needs to be hidden as when all content will be implementent all possiblites will be covered. THanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.