Create a Query

Search & Filter relies heavily on the creation of Queries. Using our Query Builder, you can easily create queries and fine-tune them to display content on your site.

Combine Search & Filter Queries with Search & Filter Fields to allow your visitors to filter down to exactly what they’re looking for, keeping them on your site for longer and increasing conversions.

Note: For this guide, you’ll need to ensure that Search & Filter version 3 is installed and up to date.

Navigate to the Query Builder

  1. Log in to your WordPress admin dashboard.
  2. Hover over the Search & Filter menu on the left side of the screen and click on the Queries option.
  3. Click on the Add new button at the top of the page.

Configure the Query Settings

  1. Next, you’ll need to add a name for your query. It won’t be visible to your users and is only used on your admin dashboard.
  2. Check that the Enabled switch is on. This switch is on by default when you first create a query.
  3. In the Location tab, you can set and change the query’s expected location, as well as the expected source of the WordPress query.

    Search & Filter can identify and modify a WordPress query to showcase different results on a page based on a user’s interaction.

    For this guide, we’ll use the default options (including keeping the Autodetect Query option turned on).

    You can also find more information on using a Shortcode to add the query to your site here.
  4. Next, click on the Query tab.

    There are a lot of different options here, so let’s try to break them down:
    • Use Indexer (Pro): This setting will enable Search & Filter’s Indexer. This feature enables faster, dynamic search and filtering. For this example, we’ll keep the feature off and rely on WordPress’ query.
    • Post types: In this field, you’ll need to specify the expected post types of the query. You can choose to add multiple post types, like Media and Pages, as well as custom post types.

      Note: Some Location types only allow specific post types (e.g. WooCommerce Shop only allows for Products).

      Depending on the post types added to this field, you’ll get different results when searching and/or filtering a query.

      For this guide, we’ll use the default Posts option.
    • Post status: Similar to Post types, this field allows you to choose multiple possible post statuses to search from.

      For now, we’ll keep the default option of Published.
    • Posts per page: This field allows you to change the number of returned posts per page for each query. You can use -1 to show all results without pagination, but for this example, we’ll keep the default of 10 posts per page.
    • Offset: Number of posts to skip (offset) in the query results. Set to 0 for this example.
    • Sort order: This option controls the appearance order of posts after a search or filter interaction has occurred. There’s a long list of options you can choose from, but for now, we’ll keep this option turned off. Here’s a screenshot of the options, though, for reference:
    • Sticky posts: You can choose to:
      • Ignore sticky posts from the results of the query.
      • Excluding them.
      • Showing them
      • or Only show sticky posts in the query.

        For now, we’ll use the default option, which is Ignore.
    • Field relationship: You can adjust the behavior between the Search & Filter fields tied to this query. For example, for a form that has multiple filters (e.g. WooCommerce product catalog with filters based on the products’ category and tag), this setting will determine whether a product will appear in the results if both filters have a valid value (Require all), or whether any of the filters has a valid value (Require any).

      For now, use the default option.
    • Exclude Current Post: this switch is set to Yes by default, and will exclude the post that the Query is added to.
  5. When you’re done with the Query tab, you can click the Save button to save your progress. In this guide, we didn’t use the following tabs:
    • The Taxonomies and Post Meta fields allow you to add more advanced conditions for the query. For example, you can show only posts from specific taxonomies or with specific post meta values.
    • The Results tab is a feature that was upgraded in version 3 of Search & Filter. Here, you can activate the Live Search option, which allows users to complete searches without triggering a page refresh. With this feature, you can create dynamic searches and filtering for your site. Click here to find out more about this feature.
    • The Accessibility tab allows you to customize specific terms used by our plugin. You can change the names or use different values for text that is readable by a screen reader. You can keep the default values or adjust as needed.

Well done! You’ve just created your first query! This is how it will look like after you have clicked on the Save button:

Connected Fields

Now that you have created your first query, it’s time to work on the form’s fields. You can click on the Fields tab of the query so that all new fields will be automatically assigned to the correct query: