Advanced Custom Fields (ACF) Documentation

repository·master·Indexed 21 days ago

https://github.com/advancedcustomfields/acf

A WordPress plugin that enables developers to add custom data fields to posts, users, taxonomies, and more. ACF provides a field builder for structured data models and includes developer-friendly functions for displaying data in theme templates. The plugin offers a free version and an ACF PRO version featuring Repeater Fields, ACF Blocks, Flexible Content, Options Pages, Gallery Fields, and Clone Fields. It includes WP-CLI commands for JSON management and requires WordPress 6.0+ and PHP 7.4+.

Tokens
2.5K
Snippets
6
Records
20
Agent score
74%

What's inside Advanced Custom Fields

  1. Overview of Advanced Custom Fields

    master
    Advanced Custom Fields (ACF) is a WordPress plugin designed to give developers full control over WordPress edit screens and custom field data. It allows for the creation of flexible, structured data models within the WordPress admin interface.
  2. Overview of Advanced Custom Fields (ACF)

    master

    Advanced Custom Fields (ACF®) is a tool for customizing WordPress by adding structured data to your content model. It allows developers to:

    • Add fields on demand: Quickly add fields to WordPress edit screens via a field builder.
    • Add fields anywhere: Attach fields to posts, pages, users, taxonomy terms, media, comments, and custom options pages.
    • Display data anywhere: Use developer-friendly functions to load and display custom field values in any theme template file.
    • Manage content models: Register custom post types and taxonomies directly within the ACF UI without writing code.
  3. Compare ACF Free and ACF PRO

    master

    While the free version of ACF provides core field building and content modeling capabilities, ACF PRO includes advanced features for complex data structures and enhanced developer workflows:

    ACF PRO Exclusive Features

    • Repeater Field: Create sets of sub-fields that can be repeated multiple times.
    • ACF Blocks: A PHP-based framework for developing custom blocks for the WordPress Block Editor (Gutenberg).
    • Flexible Content Field: Provides multiple layout and sub-field options for complex content structures.
    • Options Page: Add custom administration pages to manage global ACF fields.
    • Gallery Field: Build customizable image galleries.
    • Clone Field: Reuse existing fields and field groups to streamline field management.
  4. Install Advanced Custom Fields via WordPress Dashboard

    master

    To install the free version of ACF, follow these steps within your WordPress admin area:

    1. Navigate to Plugins > Add New.
    2. Search for "Advanced Custom Fields" or "ACF".
    3. Click Install and then Activate on the Advanced Custom Fields plugin.
    4. Once activated, click the new ACF menu item to begin creating field groups, custom post types, or taxonomies.
  5. System Requirements for Advanced Custom Fields

    master

    To use the current version of Advanced Custom Fields, ensure your environment meets the following minimum requirements:

    • WordPress: version 6.0 or newer
    • PHP: version 7.4 or newer

    Note: Older versions (e.g., 6.2.0) supported WordPress 5.8+ and PHP 7.0+.

  6. How to contribute to ACF core

    master

    If you have identified a bug in the ACF core or have a patch to provide, you can contribute via GitHub.

    1. Create a new GitHub issue providing as much technical detail as possible.
    2. Submit a Pull Request (PR) if you have a fix or improvement ready.
  7. How to translate ACF

    master

    ACF supports translations through two different methods depending on the version:

    • Free Version: Strings are automatically imported from translate.wordpress.org.
    • PRO Version: You can submit new PRO translations by submitting a Pull Request directly to this repository.

    Refer to the official translation guide for detailed instructions on how to help translate ACF into other languages.

  8. Access ACF documentation and support

    master

    For technical guidance, feature explanations, or troubleshooting, use the official documentation and support channels rather than the GitHub issue tracker.

    • Documentation: Search the official resource library for guides and feature details.
    • Support: Use the community forum or the email-based ticket system for help with ACF usage.
    • Feedback: Submit feature suggestions or general feedback via the official feedback board.
  9. Customize ACF file size calculation with `acf/filesize`

    master
    The acf/filesize filter allows third-party media plugins to bypass ACF's default behavior of calling filesize() on attachments. This is useful for preventing remote downloads when using offloaded storage (where filesize() might trigger a download if the file is uncached).
  10. Use the `escape_html` parameter in `get_field()`

    master

    The get_field() function and other get_ functions now support an escape_html parameter. When set to true, the function returns an HTML-safe field value by escaping potentially unsafe HTML.

    This is useful for ensuring that data retrieved from the database is safe for output in your templates.

    // Example of getting an HTML-safe field value
    $value = get_field('my_field_name', $post_id, false, true); // The last parameter is escape_html
  11. Limit ACF shortcode data access with `acf/shortcode/prevent_access`

    master
    For security hardening, you can use the acf/shortcode/prevent_access filter to limit which data the ACF shortcode is allowed to access. This helps prevent sensitive field data from being exposed via shortcodes.
  12. Customize ACF JSON filename with `acf/json/save_file_name`

    master
    You can customize the filename used when ACF saves JSON field group definitions by using the acf/json/save_file_name filter. This is particularly useful for managing how field groups are exported and version-controlled.