Hi, @Amine
The WPFTS Pro version you are using is very outdated. Please consider upgrading to 2.46.x which is the latest. It has a completely new indexing and searching algorithm and it should solve your issue.
Is it possible to make 2 different searches on the same website?
-
Yes, actually you can make more than one search, the number of search filters is not limited.
Each search filter can have it's own preset, which can be selected in the "WPFTS :: Live Search" widget option and thus will be automatically activated when someone makes a search with this specific widget instance.
Let me explain to you in two words how to do this.
Imagine, you want to have 2 different searches on your website: the main search (which searches for posts and pages only) and another search that will search for PDF files only.
Okay, let's say we already have the main search configured, we only need to disable the "Search in Files" option (available in WPFTS Settings > Search & Output > Filter).
Let's create another search filter that will search in PDF files only.
add_action ('init', function() { global $wpfts_core; if ((!is_object($wpfts_core)) || (!$wpfts_core)) { return; } if (method_exists($wpfts_core, 'AddWidgetPreset')) { // Repeat this block as much as you need $wpfts_core->AddWidgetPreset('pdfonly', array( // 'pdfonly' is the ID of your preset 'title' => 'PDF Only', // This is a title of your preset (shown in WPFTS :: Live Search selector) 'filter' => 'pdfonly', // This is the ID or the filter (can be the same as the preset name) 'results_url' => '/', // The results page URL, it should be existing URL on your website 'autocomplete_mode' => 1, // Should autosuggestion be ON for this widget? )); // Put another preset here if you need that // ... } }, 255);
Not hard, right? But that's not all. Now we need to force some WP_Query() parameters in case someone uses this preset.
add_action('wpfts_pre_get_posts', function(&$wpq, $wdata) { // The filter processor for the custom widget if ($wdata['id'] == 'pdfonly') { // Use your filter name here (not preset name, however they can be the same) // Let's set up specific parameters for this filter // Please refer to WP_Query() official documentation for possible parameters // The WPFTS-specific parameters also will work here, check this link for them: // https://fulltextsearch.org/docs/wpfts-api-description/extended-wp_query/ $wpq->set('post_type', 'attachment'); $wpq->set('post_status', array('inherit')); } // Repeat the filter processor block for each your widget // ... }, 20, 2);
Here is it. You need to place this code in the
functions.php
file of your current theme.When it's done, you can place the WPFTS :: Live Search widget to the specific page and then select your preset ("PDF Only" in our case) from the select box.