FacetWP – a semi-tutorial

I don’t usually usually pay for WordPress plugins but this is one I’ve come to like1 quite a bit. To start off, I have a historic interest in facet based searching. It is one of the main things that continues to appeal to me about Exhibit (one of the earlier javascript based tool libraries aimed at non-developers). I’ve looked at a lot of different options to make that kind of thing work for WordPress over the last 5 to 7 years.2 This is by far the best option I’ve found.

Why I Like It

You can see all the bells and whistles on the demo page. The brass tacks version is that it allows you create a variety of guided search options and create custom page templates with or without the search pieces. I’ve used it personally and on rampages in a few slightly different ways.

  • Here it is just using the custom display (no search) to show 3rd Space related images and I’ve used it to do something similar on this page with posts from my blog in the ‘Photography’ category.3
  • On this site, it’s allowing faceted searching based on tags created by students through a Gravity Form.
  • Another example that’s using two facets (date and work type) based on parent/child category relationships to sort out my work.

Given I’m working in a fairly large WordPress multisite environment, there are a few things that make FacetWP particularly appealing. I could create all sorts of custom child themes for various needs. That works but I worry about having lots of child themes cluttering things up, being activated on a per site basis– basically creating things that I am pretty sure no one on the user end will ever be able to take over, adjust or make for themselves. I don’t necessarily think lots of users will ever try their hand at FacetWP but the option for them to do so exists. I also like that the tool itself is not so tightly tied to a particular theme. It can travel as people change their minds and the only piece that needs adjusting will be the CSS.

How It Works

There are essentially three interrelated pieces- the facets (if you want to search/sort), the template (functional display), and the CSS (making your functional display extra pretty). You then put these within a page or post4 using shortcodes.

Facets

You can tie into a huge variety of options, including custom post type fields. You can make a lot of these and use them alone or in combination. You then add them via the shortcode based on the name you gave them- for example if I named my facet “years” then I’d embed it with the following shortcode and I could add other facets I made below it with the same naming conventions.

Screen Shot 2014-10-12 at 2.14.30 PM
Screen_Shot_2014-10-12_at_2_14_48_PM

Templates

Templates take this plugin to an entirely different level. You can do a bunch of different things here. The template has two pieces, the first is a way to restrict what shows up from the entire corpus of blog content and the second lets you define what pieces show up. It’s essentially the power to build custom page templates with lots of sophistication without having the kind of access normally needed. You embed them in the same way as facets- would embed the template named “thumbnail.”
Screen_Shot_2014-10-12_at_2_31_53_PM

CSS

Then you polish it all up with some CSS to make the facets and template pieces display the way you want within the theme you’ve chosen. I’ve started throwing up some basic combinations of these elements on Github so they’re in one place for reuse. So far the CSS has traveled well between themes.


1 Don’t try to trick me into something deeper.

2 I even went as far as creating a rather shoddy (but earnest) child theme to make it happen.

3 The CSS still needs some work.

4 You can also build it into your theme if you want to go that route.

4 thoughts on “FacetWP – a semi-tutorial

  1. That’s pretty slick- it’s doing what one might do in a mod to a theme, and giving you code level access to modify the query. And yes, on a multisite reducing the need for extra baby themes is sensible.

    You can also mod the search (but ti takes template mucking) with hidden form field elements; we do this on http://assignments.ds106.us to restrict search to a post type, an added

    input type=”hidden” name=”post_type” value=”stufftodo”

    What are “ghosts”? Should one be afraid of them?

Comments are closed.