[8.x] Install plugin as theme

A sage based theme should add an ACF powered extra field to CPTs of type “post”.

There are instructions on the ACF website: https://www.advancedcustomfields.com/resources/including-acf-in-a-plugin-theme/
However - these don’t take package management/composer into account.

Then there are at least three cases:

  1. ACF or ACF PRO are not installed/enabled
  2. ACF is available, ACF PRO is not
  3. ACF PRO is available, ACF is not

The theme should not install ACF PRO when ACF is already used - and vice versa.

I’m confused by both this thread name and what you posted

2 Likes

Sage 8.x is used as base for the theme.

The theme adds an extra field for a theme-specific option using the ACF or ACF PRO plugin.

Should the theme install the ACF or ACF PRO plugin itself?
Should a default for the option be used until ACF (PRO) was installed and user can select something?

Are you asking about a best practice? Or are you working with an existing theme?

Does the theme you’re working with already do one of these things, or are you looking for advice on how to MAKE it do one of these things?

1 Like

I want to add this to a sage-based theme. Currently the field has been added by ACF GUI,
but I want to follow best practice.

The link you posted gives you the code you need to include ACF in your theme.
If you don’t want to include it twice, only
require 'acf.php'
when:
if(!function_exists('get_field')).

1 Like

Should the theme - by best practice - suggest or even install ACF (PRO) on its own? Should it display a warning that ACF (PRO) isn’t installed - hence some features missing (the theme specific option fields)?

I don’t think it’s ever been suggested anywhere that a theme try and install a plugin. The most that a theme should ever do is say it’s suggested or required to install a plugin. It’s up to the user to actually do that though.

2 Likes