<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Is it possible to make 2 different searches on the same website?]]></title><description><![CDATA[<p dir="auto">Yes, actually you can make more than one search, the number of search filters is not limited.</p>
<p dir="auto">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.</p>
<p dir="auto">Let me explain to you in two words how to do this.</p>
<p dir="auto">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.</p>
<p dir="auto">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 &gt; Search &amp; Output &gt; Filter).</p>
<p dir="auto">Let's create another search filter that will search in PDF files only.</p>
<pre><code class="language-PHP">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-&gt;AddWidgetPreset('pdfonly', array(	// 'pdfonly' is the ID of your preset
			'title' =&gt; 'PDF Only',		// This is a title of your preset (shown in WPFTS :: Live Search selector)
			'filter' =&gt; 'pdfonly',		// This is the ID or the filter (can be the same as the preset name)
			'results_url' =&gt; '/',		// The results page URL, it should be existing URL on your website
			'autocomplete_mode' =&gt; 1,	// Should autosuggestion be ON for this widget?
		));

		// Put another preset here if you need that
		// ...
	}
}, 255);
</code></pre>
<p dir="auto">Not hard, right? But that's not all. Now we need to force some WP_Query() parameters in case someone uses this preset.</p>
<pre><code class="language-PHP">add_action('wpfts_pre_get_posts', function(&amp;$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-&gt;set('post_type', 'attachment');
		$wpq-&gt;set('post_status',  array('inherit'));
	}

	// Repeat the filter processor block for each your widget
	// ...

}, 20, 2);
</code></pre>
<p dir="auto">Here is it. You need to place this code in the <code>functions.php</code> file of your current theme.</p>
<p dir="auto">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.</p>
]]></description><link>https://fulltextsearch.org/forum/topic/54/is-it-possible-to-make-2-different-searches-on-the-same-website</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 01:33:30 GMT</lastBuildDate><atom:link href="https://fulltextsearch.org/forum/topic/54.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Dec 2020 18:58:18 GMT</pubDate><ttl>60</ttl></channel></rss>