Skip to content
delta

Recipe: a blog or a custom post type

Most client sites need a set of things with a listing page and a detail page: case studies, team members, properties, a blog. In Delta this is one job. This page shows what that job produces, and where it stops.

“Add a Portfolio section: projects with a client name, a year, and a project type taxonomy. Build the listing and the project page to match the site.”

What you get

A content type, and three templates: a card for one project, an archive that lays the cards out, and a single page for the project itself. Display conditions point the last two at the Portfolio.

That is the whole structure. Project number seven is one entry, with no template work. We built the docs on this site the same way: one card, one archive, one single page, and every article since then has been an entry.

A blog is the same job with the first step removed, since WordPress already has posts.

The one interruption

Delta has no post types of its own. We chose to drive the existing plugins rather than add a registry, and the Content types page explains that choice. So the agent names a plugin, usually Advanced Custom Fields, and stops until you answer. It does not install plugins on its own initiative.

Once the plugin is active, the agent creates the type, the taxonomy and the fields, then adds the field maps that turn your custom fields into placeholders the design can use.

Two things to check afterwards

The listing page is empty when the type was created without an archive. Ask the agent to turn the archive on; the templates do not need to change.

A page shows the literal text {{#posts}} when a loop that needs the main query was placed in a page’s own HTML. We have seen this one on our own site. The fix is one request: use a query loop on the page, or move the markup into the archive template. Loops and pagination explains the difference.

For developers

A new site has no templates, and a template with no conditions never matches. For a new type, build one archive and one single, each with a condition, or add a condition to templates the site already has. On a site upgraded from before 0.2.0, a designated default can already cover the type; edit it rather than adding a second template, unless a subset needs its own layout.

Conditions: archive → post_type_archive with the post type; single → post_type with the post type; blog home → the blog condition on an archive template. In archive markup use {{#posts}}; on a page’s own HTML there is no main query, so use {{#query:slug}}.

Related