Title: Dynamic render templates
Last modified: February 1, 2023

---

# Dynamic render templates

 *  Resolved [diondetovenaar](https://wordpress.org/support/users/diondetovenaar/)
 * (@diondetovenaar)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/dynamic-render-templates/)
 * Hi there,
 * What is best practice to load the corresponding template for each flexible layout?
 * I don’t wan’t to place the path to the template in the plugin settings. I would
   like to place those via the theme or plugin.
 * In your documentation is explained that you can use the filter ‘filter(‘acfe/
   flexible/render/template’. But if you have like 20 or more layouts, you would
   need to create 20 separate functions where each function is pointing to the location
   of one template. That sounds a bit overkill.
 * Is there a way to load every corresponding layout template from within one file?
 * For example i use the filter ‘acfe/flexible/enqueue/name=sections’ to enqueue
   one stylesheet for all layouts in admin.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/dynamic-render-templates/#post-16450235)
 * Hello,
 * Thanks for the feedback, and sorry for the late answer, I’m kinda busy with the
   upcoming patch lately.
 * As you pointed out, you have to use the `acfe/flexible/render/template` in order
   to define your own custom layouts files path.
 * [As described in the documentation](https://www.acf-extended.com/features/fields/flexible-content/dynamic-render#hook-template-render-path),
   this hook has a lot of variations, including wildcard variations which will be
   applied to layouts within a specific flexible content field. So you don’t have
   to create 20 different functions.
 * Here is a usage example:
 *     ```wp-block-code
       // note that 'name=my_flexible_content'
       // this hook will be executed on all layouts of the Flexible Content named 'my_flexible_content'
       add_filter('acfe/flexible/render/template/name=my_flexible_content', 'my_flexible_content_render_file', 10, 4);
       function my_flexible_content_render_file($file, $field, $layout, $is_preview){
   
           // check the layout name
           if($layout['name'] === 'my_layout'){
               $file = 'my-layout.php';
   
           // check another layout name
           }elseif($layout['name'] === 'my_other_layout'){
               $file = 'my-other-layout.php';
           }
   
           // return
           return $file;
   
       }
       ```
   
 * Hope it helps!
 * Have a nice day!
 * Regards.

Viewing 1 replies (of 1 total)

The topic ‘Dynamic render templates’ is closed to new replies.

 * ![](https://ps.w.org/acf-extended/assets/icon-256x256.png?rev=2071550)
 * [Advanced Custom Fields: Extended](https://wordpress.org/plugins/acf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-extended/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/dynamic-render-templates/#post-16450235)
 * Status: resolved