跳到内容

AgilePress Content Block for ACF

v1.1.0

AgilePress · 2025年12月12日 上架

Display ACF content using custom tags in HTML with support for groups, repeaters, galleries, and conditionals.

正在使用
10+
评分
暂无
累计下载
698
最近更新
2026年2月13日
需要 WordPress 6.1+已测试到 6.9.12PHP 7.0+

贡献者

AgilePress Content Block for ACF is a versatile tool developed by AgilePress that allows you to create dynamic HTML content with Advanced Custom Fields integration. It supports four powerful syntaxes for different ACF field types:

  • Simple fields: Use {field_name} for text, number, and other simple fields
  • Group fields: Use {group_name:sub_field_name} to access fields within ACF groups
  • Repeaters & Galleries: Use {{repeater_name}} HTML content with {sub_field} tags {{/repeater_name}} to loop through repeater fields and image galleries
  • Conditionals: Use {{#if field}}...{{/if}} for conditional content display with support for = and != comparisons

This block is perfect for:

  • Displaying custom field data in formatted HTML
  • Creating dynamic templates with ACF fields
  • Building complex layouts that pull data from custom fields
  • Looping through repeater fields and image galleries
  • Accessing nested group field data
  • Showing/hiding content based on field values
  • Integrating ACF data seamlessly into your content

The block provides an intuitive sidebar editor where you can write HTML and insert ACF field tags. On the frontend, these tags are automatically replaced with the actual values from your Advanced Custom Fields.

Requirements:

  • Advanced Custom Fields (free or PRO version)
  • WordPress 6.1 or higher
  • PHP 7.0 or higher

Usage Examples

Example 1 – Simple field display:

<div class="location">
  <p>Latitude: {latitude}</p>
  <p>Longitude: {longitude}</p>
</div>

Example 2 – Group field access:

<div class="contact">
  <h3>{contact_info:name}</h3>
  <p>Email: <a href="mailto:{contact_info:email}">{contact_info:email}</a></p>
  <p>Phone: {contact_info:phone}</p>
</div>

Example 3 – Repeater field loop:

<ul class="team-members">
  {{team_member}}
    <li>
      <h4>{name}</h4>
      <p>{position}</p>
      <p>{bio}</p>
    </li>
  {{/team_member}}
</ul>

Example 4 – Gallery field loop:

<div class="gallery">
  {{project_images}}
    <figure>
      <img src="{url}" alt="{alt}" width="{width}" height="{height}" />
      <figcaption>{caption}</figcaption>
    </figure>
  {{/project_images}}
</div>

Example 5 – Conditional display:

<article class="post">
  {{#if featured}}
    <span class="badge">Featured</span>
  {{/if}}

  <h2>{title}</h2>

  {{#if status = published}}
    <p class="published-date">Published: {date}</p>
  {{#elseif status = draft}}
    <p class="draft-notice">This is a draft</p>
  {{#else}}
    <p class="pending-notice">Pending review</p>
  {{/if}}

  {{#if author_name != Anonymous}}
    <p>By {author_name}</p>
  {{/if}}
</article>

Example 6 – Complex combination:

<article class="project">
  <header>
    {{#if is_featured}}
      <span class="featured-badge">Featured Project</span>
    {{/if}}

    <h2>{project_title}</h2>
    <p class="meta">
      Location: {location:city}, {location:country}<br>
      Date: {project_date}
    </p>
  </header>

  <div class="gallery">
    {{project_gallery}}
      <figure>
        <img src="{url}" alt="{alt}" loading="lazy" />
        <figcaption>{caption}</figcaption>
      </figure>
    {{/project_gallery}}
  </div>

  {{#if features}}
    <div class="features">
      <h3>Project Features</h3>
      <ul>
        {{features}}
          <li>
            <strong>{feature_name}:</strong> {feature_value}
          </li>
        {{/features}}
      </ul>
    </div>
  {{/if}}

  <footer>
    {{#if client_type = commercial}}
      <p><strong>Commercial Project</strong></p>
    {{/if}}

    <p>Client: {client_info:company_name}</p>

    {{#if client_info:email != none}}
      <p>Contact: {client_info:email}</p>
    {{/if}}
  </footer>
</article><h3>Additional Information</h3>

Security:
All field values are properly escaped using WordPress security functions (esc_html(), esc_url(), wp_kses_post()) to prevent XSS attacks and ensure safe output.

Performance:
The block uses WordPress native functions and ACF’s optimized field retrieval methods. Field values are processed server-side during render, ensuring optimal frontend performance.

Compatibility:

  • WordPress 6.1+ (tested up to 6.9)
  • PHP 7.0+ (tested up to 8.3)
  • ACF free version 5.0+
  • ACF PRO 5.0+
  • Classic and Block themes

Developer Notes:
The block follows WordPress coding standards and uses

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums