From simple portfolios to complex real estate listings and store locators, the ability to create filterable content is an extremely useful addition to any WordPress developer’s bag of tricks. In this post, I’ll give you a brief overview of five tools that can be combined to create a powerful advanced search functionality.
GenerateWP is a web-based interface for creating WordPress snippets. In this case, we would use it to create the code required to register custom post types and taxonomies. Just fill out the various fields and click update to create your ready-to-go code. Don’t forget to add a Dashicon for your custom post types! GenerateWP includes many other generators for various WordPress elements, so be sure to check those out as well.
When it comes to adding this code to your website, you should always create a plugin instead of dropping the code into your functions.php file or using another plugin to create your post types and/or taxonomies. The good thing is that the process of creating a basic plugin for these purposes is quite easy. Here’s an example of how you can structure the code:
<?php /* Plugin Name: Content Types Description: Registers custom post types and taxonomies. */ // Paste your GenerateWP output here ?>
2. Advanced Custom Fields Pro
Few plugins, if any, have fundamentally changed my development process the way Advanced Custom Fields (ACF) has. Like the name says, ACF allows you to create and manage over 30 types of custom fields that can be added to your post types, taxonomies, and even options pages. Once you’ve created your field sets, adding the calls in your templates will be come second nature once you get the hang of the general structure. From basic text and select elements to flexible content (think controlled block-based page building) and Google Maps embeds, ACF can really take your development projects to the next level.
3. WP All Import
WP All Import may be optional depending on your project, but if you’ve got a ton of content to add it’s a lifesaver. This plugin comes with an easy to use drag and drop interface that will allow you to map data from a CSV or XML file to various fields on your posts and pages. With their premium extensions, you can also map to Advanced Custom Fields, WooCommerce fields, and more. There’s also a sister WP All Export plugin if you ever need to pull the content back down from your website. If you want to get really fancy, check out the capability to schedule automated imports.
Quite frankly, the default WordPress search function isn’t very good…but it can be. Relevanssi gives you a lot more control over what content is indexed for search – post types, taxonomies, custom fields, etc. This is another plugin that may be optional, but if you plan on including a keyword-based search in your directory it is a great addition to provide better search results. Relevanssi results are weighted based on a number of customizable data points to deliver the content that is most relevant to the visitor’s search query.
Alright folks – this is where, as they say, the rubber meets the road. You’ve got your custom post types, taxonomies, and custom fields all built. The content has been imported into your website and properly indexed for keyword searches. FacetWP is going to be the tool that brings it all together for you. With 12 different types of inputs (called Facets) to choose from including checkboxes, radio buttons, drop-down selections, date/number ranges, and keyword searches. FacetWP can reference various data sources within your content to give you the powerful advanced search functionality that you’ve been looking for. The plugin comes with a visual layout and query builder for non-coders, and integrates directly with ACF (out of the box) and the Relevanssi engine (with a free extension).
Another powerful feature, provided that you are able to navigate the often questionable waters of Google Maps API requests, is the ability to use geocoded content (via an ACF Google Map with longitude/latitude data) to plot results to a map and create proximity-based searches. Goodbye crummy store locator plugins!
Lastly, I want to give a shout out to the fast, friendly, and knowledgeable FacetWP support team. Rarely do my projects fit into a standard cookie cutter mold, and the fantastic support staff at FacetWP has gone above and beyond on multiple occasions to help me implement the various scenarios that I tend to conjure up.
Filterable directories of content and advanced searches are becoming more and more common in website feature requirements that come my way, as I’m sure they are for you as well. Hopefully you have been able to take away something useful from this post that can be applied to your future projects!
Jim Ferguson has been building WordPress-powered sites for 10+ years. He is the owner of Sandlapper Creative, a web design & development company based in the suburbs of beautiful Greenville, SC.