toolbox/block_template_dirs

Estimated reading: 1 minute

This filter allows you to add a custom block directory to the paths list.

Parameters

  • $directories(array) array of absolute paths

Usage

The passed in $directories parameter is an array of directories where the ACF Block loader will search for Twig templates that are compatible.

Return value

Make sure to return as array.

Example

<?php

/**
 * add the directory 'custom-blocks' in your (child-)theme folder to the paths to search blocks.
 */
add_filter( 'toolbox/block_template_dirs' , function( $directories ) {
    $directories = array_merge( $directories , [ get_stylesheet_directory() . '/custom-blocks/' ] );
    return $directories;
} , 10, 1 );
Share this Doc

toolbox/block_template_dirs

Or copy link

CONTENTS