I just started learning timber. Timber uses twig as its templating engine.

This is great but I have a problem with displaying all .twig files in the theme editor. I'm using VS code for my code development so I have no problem viewing and accessing .twig files there.

My problem is with the built in wordpress theme editor.

Do you know of a way to show all the file/folder structure when using the theme editor? starting with displaying .twig files but would also be nice to see all file/folder structure including, vendor, composer.json etc...

1 Answer 1


The thing you need to do is update the filter with the "allowed" editor file types.

Here's what you'll need for TWIG:

function add_custom_editor_file_types( $types ) {
    $types[] = 'twig';
    return $types;
add_filter( 'wp_theme_editor_filetypes', 'add_custom_editor_file_types' );

Of course, you can add any file type/extension you wish in the same manner. The editor UI will show the directory structure only where there are "editable" files.

EDIT: Certain directories are excluded from being scanned for files, by default. One of these is vendor. This is likely because in some instances, the vendor dir will be huge and so loading and processing for this will have a cost associated with it.

To prevent vendor dir from being excluded, you can use the filter dedicated for that purpose:

function unexclude_theme_editor_dirs( $exclusions ) {
    // default exclusions: 'CVS', 'node_modules', 'vendor', 'bower_components'
    $unExclude = [ 'vendor' ];
    return array_diff( $exclusions, $unExclude );
add_filter( 'theme_scandir_exclusions', 'unexclude_theme_editor_dirs' );
  • Worked like a charm! liked and subscribed. Any idea how to display the vendor folder? (this folder is created with composer) Commented Jul 5, 2021 at 8:29
  • 1
    no problem! I've added an additional snippet so you can see the vendor dir too.
    – Paul G.
    Commented Jul 5, 2021 at 9:35
  • Fantastic!, everything that i needed, to bad I can't upvote the answer again. Upvoted the comment though =] Commented Jul 5, 2021 at 10:07
  • no sweat, glad it helps! :)
    – Paul G.
    Commented Jul 5, 2021 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.