Hi, I installed acf-composer in a sage 10 theme. Installation was successful, but now I have no idea how to run the created fields in my theme. Anyone can help?
If you have WP CLI, check the readme for commands such as wp acorn acf:field Example
.
If not, create a Fields
directory inside the theme’s app directory, then for the field itself create a new file inside this Fields
directory called Example.php
for example with the below php (more examples in the readme)
<?php
namespace App\Fields;
use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldsBuilder;
class Example extends Field
{
/**
* The field group.
*
* @return array
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example
->setLocation('post_type', '==', 'post');
$example
->addRepeater('items')
->addText('item')
->endRepeater();
return $example->build();
}
}
I install acf-composer via composer require log1x / acf-composer
and manually create config / acf.php. Then I run the command wp acorn acf: Option
. This command creates an Option.php file in app / Option. Unfortunately, I cannot see the options page in the WordPress admin. Should I do anything else in the configuration files setup.php
or 'helpers.php`?
Do you have Advanced Custom Fields Pro installed and activated?
Yes, of course. Acf 5.9.5
can you share the generated option.php file?
Installation should be straightforward. I asked about ACF installation because it happened to me a couple of times that I forgot to activate the theme or was using a different theme.
$ wp acorn acf:options Example
If you can share more info I’ll be happy to help.
This topic was automatically closed after 42 days. New replies are no longer allowed.