PHPackages                             mwdelaney/acf-flexible-content-blocks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. mwdelaney/acf-flexible-content-blocks

AbandonedArchivedWordpress-plugin[Templating &amp; Views](/categories/templating)

mwdelaney/acf-flexible-content-blocks
=====================================

A collection of useful, reusable flexible content blocks for content development in WordPress with ACF 5 Pro. Templates included and automatically loaded.

0.5(9y ago)6963818[4 issues](https://github.com/MWDelaney/acf-flexible-content-blocks/issues)MITPHPPHP &gt;=5.3.2

Since Aug 24Pushed 9y agoCompare

[ Source](https://github.com/MWDelaney/acf-flexible-content-blocks)[ Packagist](https://packagist.org/packages/mwdelaney/acf-flexible-content-blocks)[ Docs](https://github.com/MWDelaney/acf-flexible-content-blocks)[ RSS](/packages/mwdelaney-acf-flexible-content-blocks/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Advanced Custom Fields Flexible Content Blocks
==============================================

[](#advanced-custom-fields-flexible-content-blocks)

**NOTE:** This plugin is very much a work in progress. It includes a small number of layouts now, and will include more as time allows.

A WordPress plugin that provides a collection of useful, reusable flexible content blocks for use with ACF Pro 5. Basic templates included and automatically loaded, can be optionally overridden at the theme level.

This plugin creates a Flexible Content Field below the content editor on Pages and automatically includes content entered there below `the_content()` on page templates.

Also wraps `the_content()` in some basic HTML to make it easy to differentiate from the added content blocks.

[![Screenshot](/../gh-pages/screenshot.png?raw=true "Advanced Custom Fields Flexible Content Blocks")](/../gh-pages/screenshot.png?raw=true)

Requirements
------------

[](#requirements)

1. WordPress 4.5+
2. Advanced Custom Fields Pro 5

Usage
-----

[](#usage)

By default all included layouts are available:

1. Content
2. Media (image, oembed, 'content', code)
3. Content With Media
4. Featured Content
5. Slider
6. Tabs
7. Gallery
8. Collapsibles
9. Cards
10. Post List
11. Strap

### Enable only some layouts

[](#enable-only-some-layouts)

To remove layouts from the available list, declare theme support for only the layouts you wish to use:

```
add_theme_support( 'flexible-content-blocks', array( 'content', 'content-with-media' ) );

```

### Change post type blocks appear on

[](#change-post-type-blocks-appear-on)

By default content blocks are enabled for Pages, to define which post types blocks should be available on, declare theme support:

```
 $landing_page_templates = array(
   array (
     array (
       'param' => 'post_type',
       'operator' => '==',
       'value' => 'page',
     ),
     array (
       'param' => 'page_template',
       'operator' => '!=',
       'value' => 'template-no-header-image.php',
     ),
   ),
 );
 add_theme_support( 'flexible-content-location', $landing_page_templates );

```

Templates
---------

[](#templates)

Basic templates for each layout are included. These templates are designed to be simple for styling via your theme. To override the included templates, copy the template(s) you wish to override from `templates` to your theme in a sub-directory called `fcb-templates`

### Base template wrapper

[](#base-template-wrapper)

The layout base can be overridden on a per-block-type basis. When a block is rendered, the plugin will first look in your theme, and then in the plugin directory, for `layout-base-[layout_name].php` (e.g. `layout-base-content_with_media.php`) if a specific base doesn't exist, the plugin will load the `layout-base.php` template.

### Layout-specific template parts

[](#layout-specific-template-parts)

Like the base template, each template part's file name can be appended with a layout name (like `content_with_media` to override the template for that layout only. For example, `[your-theme]/fcb-templates/blocks/parts/block-cta-content_with_media.php` will be loaded only for calls to action in the "Content with Media" layout.

Actions and filters
-------------------

[](#actions-and-filters)

Several filters are available to alter the plugin's output.

### Filter: fcb\_bg\_colors

[](#filter-fcb_bg_colors)

Change or add to the available "theme" background colors for blocks

```
add_filter( 'fcb_bg_colors', 'custom_bg_colors');
function custom_bg_colors($array) {
    $array['secondary'] = 'Secondary';
    return $array;
}

```

### Filter: fcb\_btn\_colors

[](#filter-fcb_btn_colors)

Change or add to the available button colors for block calls to action

```
add_filter( 'fcb_btn_colors', 'custom_btn_colors');
function custom_btn_colors($array) {
    $array['secondary'] = 'Secondary';
    return $array;
}

```

### Filter: fcb\_set\_block\_htag

[](#filter-fcb_set_block_htag)

Set the tag that block titles are wrapped in. This defaults to ``. First remove the existing filter and then add your own:

```
/**
* Make the first block title an h1 and subsequent blocks default to h2
*/
remove_filter( 'fcb_set_block_htag', 'block_htag_level', 10 );
add_filter( 'fcb_set_block_htag', 'custom_htag_level', 10, 2 );
function custom_htag_level($title, $htag) {
    if($GLOBALS['fcb_rows_count'] == 0) {
        $htag = 'h1';
    } else {
        $htag = 'h2';
    }
    return '' . $title . '';
}

```

### Filter: fcb\_set\_block\_wrapper\_classes

[](#filter-fcb_set_block_wrapper_classes)

Set the classes applied to content block wrappers. This filter runs each time a block is rendered, so classes can be conditionally applied per-block.

```
/**
* Give the first block an additional class of 'block-first'
*/
add_filter( 'fcb_set_block_wrapper_classes', 'custom_block_wrapper_classes' );
function custom_block_wrapper_classes($classes) {
    if($GLOBALS['fcb_rows_count'] == 0) {
        $classes[]   = 'block-wrapper-first';
    }
    return $classes;
}

```

### Filter: fcb\_set\_block\_classes

[](#filter-fcb_set_block_classes)

Set the classes applied to content blocks. This filter runs each time a block is rendered, so classes can be conditionally applied per-block.

```
/**
* Give the first block an additional class of 'block-first'
*/
add_filter( 'fcb_set_block_classes', 'custom_block_classes' );
function custom_block_classes($classes) {
    if($GLOBALS['fcb_rows_count'] == 0) {
        $classes[]   = 'block-first';
    }
    return $classes;
}

```

### Filter: fcb\_set\_block\_wrapper\_styles

[](#filter-fcb_set_block_wrapper_styles)

Set the styles applied to content blocks. This filter runs each time a block is rendered, so styles can be conditionally applied per-block.

This filter isn't recommended for use --it's used by the plugin to apply background styles which are set in the block. Semantic styles are always preferrable to style attributes applied per block.

```
/**
* Give the first block an ugly green border
*/
add_filter( 'fcb_set_block_wrapper_styles', 'custom_block_styles' );
function custom_block_styles($styles) {
    if($GLOBALS['fcb_rows_count'] == 0) {
        $styles[]   = 'border: 1px solid green;';
    }
return $styles;
}

```

### Filter: fcb\_content\_before

[](#filter-fcb_content_before)

This plugin armors the main WordPress content (`the_content()`), by default. This filter can be used to modify the armor and output of `the_content()`.

```
**
 * Add "Contact Us" button before the_content() on landing pages
 */
add_filter( 'fcb_content_before', 'contact_us_button', 10 );
function contact_us_button( $content ) {
    if ( on_landing_page() && !empty($content))  {
        // Add image to the beginning of each page
        $content = sprintf(
            '%s%s',
            "Contact Us",
            $content
        );
    }
    // Returns the content.
    return $content;
}

```

### Filter: fcb\_content\_after

[](#filter-fcb_content_after)

This plugin armors the main WordPress content (`the_content()`), by default. This filter can be used to modify the armor and output of `the_content()`.

```
**
 * Add "Contact Us" button after the_content() on landing pages
 */
add_filter( 'fcb_content_after', 'contact_us_button', 10 );
function contact_us_button( $content ) {
    if ( on_landing_page() && !empty($content))  {
        // Add image to the beginning of each page
        $content = sprintf(
            '%s%s',
            "Contact Us",
            $content
        );
    }
    // Returns the content.
    return $content;
}

```

### Filter: fcb\_get\_layouts

[](#filter-fcb_get_layouts)

Change the PHP class that the plugin looks at for layouts. See [Adding Your Own Layouts](#adding-your-own-layouts).

Adding Your Own Layouts
-----------------------

[](#adding-your-own-layouts)

You can append your own layouts to the included set using a filter:

```
/**
 * Add layouts to ACFFCB
 */

 function my_layouts() {
  // The name of the class we keep our layouts in
 	return 'myLayouts';
 }

add_action( 'acf/init', function() {
  // Remove the plugin's set default set of layouts
	 remove_filter ('fcb_get_layouts',  'fcb_layouts_class', 99, 2);

	 // Add my own layouts
	 add_filter ('fcb_get_layouts',  'my_layouts', 99, 2);
});

// Extend the original class to include all the default layouts as well as the ones we're adding here.
class myLayouts extends MWD\ACFFCB\Layouts {

  /**
  *
  * Flexible Content Field: Call to Action
  *
  * @author Michael W. Delaney
  *
  */
  function feature() {
   $FCBFields = new MWD\ACFFCB\Fields(__FUNCTION__);
   $FCBRepeaters = new MWD\ACFFCB\Repeaters(__FUNCTION__);
   $FCBFlexibleContent = new MWD\ACFFCB\FlexibleContent(__FUNCTION__);
   return(
    array ( 'order' => '1000',
    'layout' => array (
     'key' => __FUNCTION__,
     'name' => 'call_to_action',
     'label' => 'Call to Action',
     'display' => 'block',
      'sub_fields' => array (

       // Call to Action
       $FCBFields->tab_cta(),
       $FCBFlexibleContent->cta(),

       // Tab Endpoint
       $FCBFields->tab_endpoint(),

      )
     )
    )
   );
  }
 }

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3597d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2457670?v=4)[Michael W. Delaney](/maintainers/MWDelaney)[@MWDelaney](https://github.com/MWDelaney)

---

Top Contributors

[![MWDelaney](https://avatars.githubusercontent.com/u/2457670?v=4)](https://github.com/MWDelaney "MWDelaney (193 commits)")

---

Tags

pluginwordpressadvanced custom fields

### Embed Badge

![Health badge](/badges/mwdelaney-acf-flexible-content-blocks/health.svg)

```
[![Health](https://phpackages.com/badges/mwdelaney-acf-flexible-content-blocks/health.svg)](https://phpackages.com/packages/mwdelaney-acf-flexible-content-blocks)
```

###  Alternatives

[mwdelaney/sage-acf-gutenberg-blocks

Create Gutenberg blocks from Sage blade templates and ACF fields.

352370.9k1](/packages/mwdelaney-sage-acf-gutenberg-blocks)[palmiak/timber-acf-wp-blocks

Create Gutenberg blocks from Twig templates and ACF fields.

25075.2k2](/packages/palmiak-timber-acf-wp-blocks)[benjaminmedia/wp-polylang-theme-strings

Polylang Theme Strings with support for Blade syntax

1510.0k](/packages/benjaminmedia-wp-polylang-theme-strings)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
