1. Dallas Johnson
  2. Widget Relationship Field Add-On for Advanced Custom Fields

Overview

HTTPS SSH

About

This plugin is an add-on for Advanced Custom Fields. It allows you to use an ACF "relationship" field to choose widgets at a page level.

Installation

Create a folder named advanced-custom-fields-widget-relationship-field-add-on in your plugins directory. Unzip and copy files to this directory. Activate plugin in WP admin.

Usage

Edit your template`s sidebar file(s)

In sidebar.php, replace default dynamic_sidebar() function with the new dynamic_widgets() method:

if ( ! acf_Widget::dynamic_widgets( 'Side Bar' ) ) {

   //fallback to default function if you like
   dynamic_sidebar( 'Side Bar' );

}

Add new ACF Field

Add a new ACF field to your ACF Field Group. Select Widget Relationship from the field type option. Set the Sidebar, Inherit From and Menu Location options as desired.

Configure your widgets

In WP Admin, go to Appearance, then Widgets and configure ALL widgets you'd like to use. This will be your "pool" of available widgets.

Select desired widgets from the page level

Assuming you applied the ACF Field Group to the page post type, in WP Admin, go to Pages, then edit a page. You should have a new relationship field for each sidebar set to use a Widget Relationship field. Select the widgets you'd like to display on the page - select ----Inherit from Parent---- to include all of the parent page's widgets as well. Drag the options around to sort them in your preferred order.