ACF Engine Project Flow from A-Z

We begin with the install of a blank WordPress site. No plugins installed, only the latest Twenty Twenty Two theme in the themes directory. First we install the Dynamic Drive theme. This is a block theme, so the Site Editor released in WordPress 5.9 remains available as we change from the default WP theme to our dynamic ACF Engine powered theme.

Next we install ACF Engine. This is our only plugin for the site and the entire project other than utilities that we might use along the way.

We create the Exercise Custom Post Type. A few extra supports options are chosen including Featured Thumbnail and Author support. It is otherwise a default post type creation. We make 4 testing posts so that we have something to render in our Query Loop.

First problem is finding the archive that was supposed to be created with the post type. We need to stop prefixing the user created post types.

Next problem was that ACF Engine plugin was outdated and needed to be updated first.

The Query Loop did not work as expected, it showed results for “post” instead of the custom post type for the archive. This is despite it having the setting “inherit query” which seems like it should inherit the current archive query. This might be a Query Loop bug.

Using the ACF Engine Template “archive” type works, but because it already does a loop instead of query loop block we need to use dynamic output blocks like “Post Title”.

Steps to provide custom archive using the post type are:

  • Create the archive override template in the theme under /templates/archive-{post-type-slug}.html
  • [optional] Add the template to the theme.json definition. This is optional, but doing so allows you to name the template which makes it look nicer in the Site Editor menu’s.
  • Add a query loop to the archive template. The default archive template already has a query loop with “inherited query”. We need to turn off that query inheritance and instead set the query loop to use our custom post type.

Taxonomy registration went pretty well, removed the automated prefixing during registration so both taxonomy and post type object setting match without prefixes which seems more intuitive. Registered “Body Parts” and assigned several exercises the appropriate category.

When adding a filter it loaded with the first level of options. Second level of terms was not shown. Filter did not work, no results were shown after filtering with a category that had items.

There was a major problem with filtering because it is different getting the wp_template content compared to getting the post ID of the current page. Because the wp_template has the Query Loop block, we have to find that and the current page/post ID doesn’t help, especially with a custom post type archive page. It is fixed now but with one limitation, the Query Loop has to be either at the top level or second level of the template block hierarchy.