You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a number of ACF groups (example below) as gutenberg blocks which I need to use across pages and posts, however the blocks are only available in pages and not posts, and they don't even appear when I search for them.
I've included an example of an ACF group I've created as a block below:
<?php
namespace App;
use StoutLogic\AcfBuilder\FieldsBuilder;
$newsletter = new FieldsBuilder('newsletter');
$newsletter
->addText('heading')
->addWysiwyg('content')
->setLocation('block', '==', 'acf/newsletter');
acf_add_local_field_group($newsletter->build());
functions.php
add_action('init', function () {
if (function_exists('acf_add_local_field_group')) {
// Gutenberg blocks
collect(glob(config('theme.dir') . '/app/fields/blocks/*.php'))->map(function ($field) {
return require_once($field);
})->map(function ($field) {
if ($field instanceof FieldsBuilder) {
acf_add_local_field_group($field->build());
}
});
}
});
Just to confirm, I need this block to be available on posts as well as pages.
The text was updated successfully, but these errors were encountered:
I haven't used blocks, nor have I tried to use ACF with blocks, so my knowledge on the requirements of getting them working is very small.
Where is the block itself getting defined, when I search ACF's docs, there is a function called acf_register_block_type, and in that you can pass the post types which it should be available to:
Just going to leave this here, but we have a lightweight "framework" that works seamlessly with ACF Builder and ACF Blocks, in case anybody wants to use it OR pick it apart for their own use! 👍🏻 It will auto register blocks that are located within a certain folder, and has built in template toggles for determining which post types the block will be available on.
I've created a number of ACF groups (example below) as gutenberg blocks which I need to use across pages and posts, however the blocks are only available in pages and not posts, and they don't even appear when I search for them.
I've included an example of an ACF group I've created as a block below:
functions.php
Just to confirm, I need this block to be available on posts as well as pages.
The text was updated successfully, but these errors were encountered: