ACF Extended give us a Block Types UI for creating custom Gutenberg blocks with ACF, making it easier than writing all the code out ourselves. The problem is, it wants us to store the templates files, the styles & scripts inside a theme.
Although the description says that the URL for render template can be either relative path or a full path to any file, the theme directory has been hardcoded in with no settings or filter to change it.
I was in contact with the developers and they have put in the feature request to include a filter for changing this, so Oxygen users can then store the files for the blocks inside a custom plugin.
When that happens, this post will be updated with information on how to use the filter inside a plugin, until then there is another way..
The short term solution is to edit our wp-config.php file and manually define both the ACFE_THEME_PATH and ACFE_THEME_URL, which is what ACF Extended uses for the theme URL and path.
Digging inside ACF Extended’s code we find this.
$this->define('ACFE_THEME_PATH', get_stylesheet_directory()); $this->define('ACFE_THEME_URL', get_stylesheet_directory_uri());
We need to define these ourselves with a plugin equivalent.
Let’s say our plugin directory is ‘custom-plugin’. Then we could use this code inside the wp-config.php file to change both the path and the URL to our custom plugin…
define('ACFE_THEME_PATH', ABSPATH . 'wp-content/plugins/custom-plugin'); define('ACFE_THEME_URL', 'https://www.website.com/wp-content/plugins/custom-plugin');
We just need to make sure the URL is changed to our current site’s URL and the directory matches the custom plugin where the files are being kept.
We can now see from inside the block type UI the new URL for us to use for the render template and for enqueuing our assets in the next tab.
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.