Code snippets
40 ACF code snippets, from basic field retrieval to block registration, the REST API and WooCommerce. Copy one into your theme or plugin and change it to suit.
Kept by Hookturn ·
- Add ACF Field Values as Admin Columns admin
- Add Custom Validation to an ACF Field hooks
- Add a Preview Image to an ACF Block blocks
- Auto-Generate Post Title from ACF Fields hooks
- Check if ACF is Active Before Using Its Functions configuration
- Create a Front-End Form with ACF field-types
- Create an ACF Block with InnerBlocks blocks
- Use Human-Readable ACF JSON Filenames json
- Detect Preview Mode in ACF Block Templates blocks
- Display ACF Fields on WooCommerce Product Pages woocommerce
- Display an ACF Gallery Field as a Responsive Image Grid field-types
- Display ACF Select and Checkbox Field Labels field-types
- Dynamically Populate an ACF Select Field's Choices hooks
- Expose ACF Fields in the WordPress REST API rest-api
- Fetch ACF Options Page Fields via REST API rest-api
- Format ACF Field Values in REST API Responses rest-api
- Get ACF Field Values from an Options Page options
- Get ACF Fields from Taxonomy Terms field-types
- Get ACF Fields from User Profiles field-types
- Get an ACF Image Field with All Sizes field-types
- Get the Additional CSS Class on an ACF Block blocks
- Get All Fields from a Field Group Programmatically hooks
- Include ACF Fields in WordPress Search Results querying
- Loop Through an ACF Repeater Field field-types
- Programmatically Update ACF Fields hooks
- Query Posts by ACF Field Values with WP_Query querying
- Query Posts by ACF Relationship Field querying
- Register an ACF Field Group via PHP configuration
- Register an ACF Block with block.json blocks
- Run Code After ACF Fields Are Saved hooks
- Store ACF pro license key in WordPress PHP configuration
- How to update an ACF Google Map field programmatically using PHP
- Register a super simple toolbar for ACF's WYSIWYG field
- Load ACF JSON files from multiple locations
- Split an ACF Flexible content field into Template Parts
- Hide the ACF Admin Menu Item on Selected Sites
- Convert an ACF Field Group from PHP to ACF-JSON
- Register Google Maps API Key for ACF
- Register an ACF Options Page
- Speed up ACF backend loading time
From Hookturn, who keep this site
ACF Theme Code Pro
Stop writing ACF template code by hand. ACF Theme Code Pro generates the PHP you need for any field type, including Repeater, Flexible Content and Gallery.
From Hookturn, who keep this site
ACF Custom Database Tables
Querying ACF fields with meta_query is slow on large sites. ACF Custom Database Tables moves your field data into dedicated tables for dramatically faster queries.
Stay updated
Get ACF tips and new extensions in your inbox. No spam. Unsubscribe anytime.