WPC Directory

We developed this plugin for our own use on WPMondo, to display a directory of companies, freelancers, founders, CEOs, key contacts) in the WordPress ecosystem.

WPC Directory is a directory you design yourself. You don’t get a fixed “business listing” format: you define your own entry types (people, companies, products; or bands, albums, songs, labels), give each type its own fields, and link entries to each other. It’s built only on native WordPress features: one post type, block bindings, the Interactivity API and DataViews. It needs a block theme but no particular one.

Defining the structure

  • Types & Fields screen: a React admin screen built on DataViews, where you create types, their fields, and the links between types. The whole design lives in one saved setting.
  • Field types:
    • Text, number, date, yes/no, URL, email, phone, colour, a 0–5 rating, gallery, address, and choice lists up to three levels deep.
    • Group fields, where one field holds several sub-fields per row (a repeater).
    • Any field can be marked repeatable.
  • Dates can be partial: a year, a year and month, or a full date (useful for “formed 1990”).
  • Validation and conditions: each field can have its own validation rules, and can be shown only when another field has a certain value.
  • Groups: separate sub-directories whose types never mix, each with its own archive at /directory-group//.
  • Free-form tags shared by every type.

Relationships

  • Entries link to each other many-to-many (band ↔ albums, company ↔ people, musician ↔ albums), stored in their own table so they can be read from either side.
  • The links themselves can have fields, for example a person’s role or dates at a company.
  • The entry editor has a picker to choose related entries, and related entries can be shown on the front end with a block.

Front end

  • Pretty URLs per type: /directory/band/opeth/ and /directory/band/, even though there’s only one post type behind them.
  • Field display: core blocks show the fields through block bindings, and a fields block shows a whole set at once (phone numbers as call links, colour swatches, stars, galleries).
  • Browsing and filtering, two ways:
    • A simple all-in-one list block: a grid with search, a type filter and filters on field values.
    • Separate filters and entry-card blocks to use with the core Query Loop (which gets its own Directory variation), sharing their state through the Interactivity API.
    • Filtering reloads the results from the server without a full page load, so entries beyond what was first rendered are always included.
  • Maps: OpenStreetMap/Leaflet with no API key. Addresses get their coordinates from Photon through a server-side proxy. There’s a single-entry map and a map with many pins, and both still show a basic map without JavaScript.

Members, claims and submissions

  • Public submission through Fluent Forms: each type gets its own form, and a submission becomes a pending entry. A logged-in submitter becomes its owner.
  • Claiming: a member can claim an existing entry. Claims are approved by hand or automatically, and can require FluentCRM tags (including “sponsor” tags).
  • Edits by owners are moderated: changes to a published entry are held for review before they go live. Each field can be closed to member editing.
  • Other member pieces:
    • A “Directory Member” role.
    • A simplified admin for members.
    • A Claims & edits review screen.
    • Notification emails.
    • A my-listings block, and a “managed by” display on entries.

Data in and out

  • Export/import: one JSON bundle holds the structure, the entries, their links and optionally the settings. It can be limited to one group, and it can merge into or replace what’s already there.
  • WPGraphQL: types, fields and relationships are exposed when WPGraphQL is active.
  • REST API under wpc-directory/v1.
  • French-ready: a .pot file exists.