Pods Framework and the WordPress block editor

A collection of experiences using the Pods Framework together with the WordPress block editor and a kind of "dynamic content".

I needed a database

A simple member database with job postings was desired for a WordPress website in the fall of 2022. I needed to categorize members into regions, associate job postings to the individual member, and support the built-in search function.

I also needed a user-friendly backend for the everyday editor, as well as a solution I can readily expand on, years after we’ve gone live.

Why Pods Framework?

Pods Framework and WordPress 6+ work surprisingly well together. Using Pods is in many ways simpler than using Advanced Custom Fields or Metabox. Pods has built-in functionality for most things: custom post types, custom fields, templates, relationships, WordPress blocks – it’s all included.

You can almost build templates without knowledge of PHP, HTML or CSS, although – as always – it’s an advantage to know a bit about what goes on under the hood.

But isn’t Pods Framework difficult to use?

Pods Framework is a free open-source plug-in. There is no premium model. Funds for the project are voluntary donations. This may also explain why the tutorials are lacking sometimes, or why Pods can appear a bit sharp at the edges.

Therefore, here is a brief summary of my experience with Pods version 2.9.x. If you find inspiration to use Pods in new contexts, please leave a comment below.

Prefix field names with the name of the content type

When naming fields for a content type, also called Custom Post Type (CPT), prefix the field name, possibly with the slug you use for the content type. The prefix makes it easy to find the fields in Pods Templates and Magic Tags

Export and import Pods settings or content

You can export Pods settings, CPTs and templates from one site and import them on another. You can select individual CPTs for export and omit others.

To export and import the content itself, you can use WordPress’ built-in export/import functions or WP All Export and WP All Import.

If you use Featured Image in your content, check the plugin Export media with selected content. This allows you to include the image in the export of a single CPT, instead of exporting all content.

Display content from a taxonomy with the Pods Field Value block

Categories and tags are taxonomies. These have standard fields you can display with the Pods Field Value block.

Interesting fields of taxonomies are name, slug, description or count.

Build layouts with the block editor and copy to templates

You can jumpstart simple layouts into templates with the block editor. Build the layout and select Edit as HTML. You can paste the HTML into the Pods Templates Editor and start replacing static content with Pods Magic Tags

Show filtered list of Pods Item List block

If you only want to display content associated with a selected taxonomy, you can use the Pods Item List’s where field. In the example below, I check if region.slug = "nordjylland". I could also have checked the region’s ID, but its slug is easier to read.

Note that you can use the order by field to sort the list – in this case by city name.

Make the search function include content types and taxonomies

By default, WordPress’ search function only searches for built-in content types, i.e. pages and posts. It can be extended to include custom post types and taxonomies. There are many tools to extend the search functionality of WordPress – WP Extended Search is a straightforward solution.

I chose to go with Relevanssi this time for better control of the weighting of the different fields.

Relevanssi allows you to index selected content types, taxonomies and fields.
Relevanssi allows you to index selected content types, taxonomies, and fields.

The block editor does not have “conditional display”, e.g. “only display the link to available jobs if there are any available jobs”. But you can use the Pods Item List for just that purpose:

  • Insert and configure a button
  • Copy the HTML code and delete the button again
  • Insert a Pods Item List block
  • Select the CPT you want to check has content
  • Paste the HTML code for the button into the Custom Template
  • Set limit to 1 so you only get 1 button

You have the option to display something else with the Not Found field, in case there is no content in the CPT. Or you can leave the field empty and nothing will be displayed.

Show me your Pod

I’ve only scratched the surface of the Pods Framework briefly, but I like it more and more every time I use it in a project. Yes, it has its quirks, but it also has its unique capabilities.

I don’t claim to be a Pods expert – and if there are smarter or more effective methods than the ones I use in this article, I’d love to hear from you. 🍃

Read more about Bjarne Oldrup, Sønderborg

Bjarne Oldrup

Bjarne is a web developer with a passion for the sustainable, inclusive and respectful internet.

With a background as a computer technician anno 1992, he worked as a programmer, sysadmin and network specialist. Today, he focuses on website carbon footprint, web accessibility and GDPR compliance.

WordPress, HTML, CSS and LiteSpeed hosts are Bjarne's favourite tools, and the open-source community is his comfort zone.

Leave a Reply

Your email address will not be published. Required fields are marked *