Turning An Easy Pod Into A Search Form

Example of how to use the Caldera Easy pods Query to return results of a search.

cf-bannerBy default, Caldera Easy Pod queries are built using either static values, or using magic tags, such as parts of the URL, or information about the current post. The use of magic tags is detailed in this doc. When the free Caldera Forms plugin is activated you can use a Caldera Form to generate a search form for your Easy Pod.

Connecting A Caldera Form To An Easy Pod

For the Caldera Answers Search on this site, I created an Easy Pods query, linked to a Caldera Form. In order to do so, I first created a simple form using the Caldera Forms editor. In it I added three fields and a submit button.  The three fields are “name,” “topic”, and “author”. The name field is a text field, while the other two are drop-down fields.

The Caldera Forms editor for the Caldera Answers search form.

Once this form exists, it can be bound to the Easy Pod by selecting this form inside of the “Search Form” tab:

 

In this tab, I also set one of my Pods Templates as the template for outputting results. In addition I set the “Live Search” option to enable the results to update automatically as a user searches, and I also set the “Run search on page load” to show results on the initial page load.

Settings for creating a Pods search using Caldera Easy Pods

Automatically Populating Field Options

Automatically populate field options with Caldera FormsFor the two drop-down fields, “topics” and “author”. These two fields are automatically populated using Caldera Forms’ “Auto Populate” option.  Since “topic” is a custom taxonomy of the “answers” post type, and “author” is a Pods relationship field, related to the “Answer Author” post type this worked out well. I simply selected the taxonomy or post type as the “Auto Type”.

By default, for select field types, Caldera Easy Pods will use the options set in Caldera Forms for the fields options. This applies if the options were entered manually or generated automatically.

An additional option, which I did not use in the Caldera Answers Search, is the ability to use the result of a separate Easy Pods query as the select options.

 

How to set search form options with another Caldera Easy Pod.

Using Search Results In Your Query

For the actual query editor, I created three groups, that results would be returned if any of the three options were used, and be refined when more than one was in use.  In the query editor you can use the values of the search form field using the syntax {search::field_name}.

For example, to query by the topic field, I used {search:answer_topic} in a field that checks for matches against topic.name, IE the names of terms in the topics custom taxonomy.

Here is a screenshot of the query builder, with all three query groups:

Example of how to use the Caldera Easy pods Query to return results of a search.

Notice that for “name” I used a “CONTAINS” comparison, instead of an exact match using an “=” comparison. Choosing this option allows for someone to search for “WP_Query” and see all answers that have “WP_Query” in the title. If I used an “=” operator, they would receive no results.For the other two options I used the “=” comparison since those I wanted exact matches.