Skip Navigation

[Resolved] Custom search not working with taxonomy and text search

This support ticket is created 7 years 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Author
Posts
#588970

I am trying to:
Create a search in a custom post type "Documents".
I want to search with "Document categories" and "text search"

I've created the search form, and the text search works, but nothing happens when I select the "Document category" and click search.

Link to a page where the issue can be seen:
hidden link

I expected to see:
I expected the search results would also change when selecting a category and searching. Each document is assigned a category.

Also I would like that the search results (the list below the search form) is hidden until the search is done. So nothing but the search form, until I have searched.

Instead, I got:
Only the text search is working. It's always showing all the posts from the custom post type.

Thanks for your time
Lykke

#588981

Hi, can you share a screenshot showing the settings in your View Editor screen? Please go to the Screen Options tab in the top right corner of the screen and activate all sections of the View, then take screenshots to show the entire page. I'll review your settings and see if anything seems to be incorrect.

#589271
view-part5.JPG
view-part4.JPG
view-part3.JPG
view-part2.JPG
view-part1.JPG

Hi Christian,

Thanks a lot 🙂

I've attached the images!

Best regards,
Lykke

#589523

Thanks, I can see that you're running into a known issue reported here:
https://toolset.com/errata/betheme-options-page-is-not-working-when-views-2-5-0-is-activated/

The latest version, Views 2.5.1, includes a permanent fix for this issue. Please update to the latest version Views and other Toolset plugins and let me know if you continue to experience problems here. You should not find any code in your Filter Editor surrounded by {!{...}!}, which indicates a problem.

#589831
FILTER-EDITOR.JPG

Hi again 🙂

I updated all plugins, but it's still not working.

I've attached an image of the filter editor. There is a recommendation in the top, but every time I click it, the search button and reset link disappears, and I have to add the text search again, to get them back.

By the way, is it correct that I can only show the content in the category dropdown, if I have selected full page refresh? When I select an Ajax option, the dropdown is empty.

Hope you can help,
best regards, Lykke

#589917

I don't think the update will fix existing filter shortcode problems, only prevent them in the future. So these filter shortcodes need to be recreated, or updated to use the correct format, now that the plugin has been updated correctly. Everywhere you see the following enclosing braces in your filter editor:

{ ! { ... } ! }

...those characters should be replaced with enclosing square brackets:

[ ... ]

You can do this manually, or you can delete the filters completely and insert them again using the GUI. They should be formatted appropriately when re-inserted. At that point, you should no longer see the missing query filter message. Let me know if that's not the case and I'll take a closer look.

#590835
New-view.JPG

Hi 🙂

I changed the view to this, see image. Is that correct?

But the search on the document categories is still giving no result. It's just updating the page when I click "search" and then all the documents are still listed.

Also remember I asked if there was a way I could hide all search results to begin with, so there's only results if a search is performed.

Thanks for your time,
Best regards, Lykke

#590993

At this point, I think it's probably best for me to take a look in your wp-admin area to see what's going on. If I need to make any changes, I will use the Duplicator plugin to create a clone of your site and install it locally so I do not disturb your live site. If that's okay with you, please provide login credentials in the private reply fields here.

#595414

Hi again Christian,

Please don't forget the part about hiding the search results, until the search is performed.

Thanks for your time
Best regards
Lykke

#595674

To hide results until some search criteria has been added, you can use the following code template:

add_filter( 'wpv_filter_query', 'drop_empty_search_query', 10, 3 );
function drop_empty_search_query( $query_args, $view_settings, $view_id ) {
    $ids = array(1,2,3);
    if (in_array($view_id, $ids)){
      if ( !isset($_GET['wpv-some-param'])  ) {  // test the GET super global to see if specific URL params are set
        $query_args['post__in'] = array(0);
      }
    }
    return $query_args;
}

Replace 1, 2, 3 with a comma-separated list of Views IDs. Each of the Views you include will show no results until some search parameters are added. You must also modify the conditional to test each possible URL parameter where I added the comment. For example, if you have two filters, you need to test them both using !isset():

if ( !isset($_GET['wpv-some-param']) && !isset($_GET['wpv-some-other-param'])  ) {

The URL parameter names should be visible in the URL bar whenever you submit your form and the URL is updated.

I'm still working on the site clone, Duplicator was giving me timeout issues so I have switched to another clone tool. Please standby.

#595688

Sorry, I've been unable to create a clone of your site using either of the tools I have access to. Duplicator and All in One WP Migration have both failed to produce usable site clones. In order to proceed, I'll need you to create a clone manually.
- Zip up all the site files into a new zip archive
- Export your database into a SQL dump file.
- Post both of these items online somewhere I can download them. I will activate private reply fields here so you can share in confidence.