Programmatically populating ACF field values in WordPress

ACF has a handy acf/load_field filter for programmatically filling the choices of field types like 'Select' that have multiple values.

This Pro tutorial provides an example of how to set the values of a Select-type field with the names and labels of all public post types in the site.

Notices how Choices are empty.

Now let's use the acf/load_field filter to automatically populate the choices with public post types minus attachments and Bricks templates.

Result after implementing the tutorial:

Step 1

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Font Awesome Field in Bricks

ACF Font Awesome Field in Bricks

We walk through using the Advanced Custom Fields: Font Awesome Field plugin for showing Font Awesome icons.
Categories:
Tags:
Pro
Random Row from ACF Repeater in Bricks

Random Row from ACF Repeater in Bricks

In the past, we shared how the first row of a ACF Repeater can be output in a Bricks query loop here. This Pro tutorial…
Pro
Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Updated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…
How to Add a Custom Control Field to an Element in Bricks

How to Add a Custom Control Field to an Element in Bricks

In this tutorial, we'll learn how to add a custom control field to an element and dynamically change a CSS property inside the builder. Introduction…
Categories:
Tags:
Pro
ACF Taxonomy Field Value in Single Posts

ACF Taxonomy Field Value in Single Posts

Consider this scenario: CPT: Movie Movie CPT Taxonomy: Movie Genre Movie Genre Taxonomy's field: Genre Color Each movie will have only genre set. The requirement…
Categories:
Tags:
Pro
Category Grid with ACF Images in Bricks

Category Grid with ACF Images in Bricks

Creating a grid of post categories, each category card showing an image from an ACF field, category name & description.
Categories:
Pro
Bricks Slider Images From ACF Flexible Content Sub Field

Bricks Slider Images From ACF Flexible Content Sub Field

Consider the following field group associated with Pages when using ACF Pro: "Page Fields" field group|_"Page Content" Flexible Content field|__"Layout 1" layout|___"Title" Text field|___"Layout 1…