• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

How to change the theme directory on a WordPress installation

Wordpress · July 20, 2022

The beauty in WordPress is not only its ecosystem. It’s the ability to customise almost every facet of it using a filter or hook.

I had a scenario recently where I wanted to put a web application theme in a less painful directory to access. I wanted a folder called themes in my root directory.

Instead of wp-content/themes/my-app-theme I wanted themes/my-app-theme instead.

The structure resembles something like this:

themes
my-app-theme
wp-content
wp-includes
index.php
wp-config.php

We can tell WordPress about a new place to look for themes. It’s not a filter or hook, it’s a function called register_theme_directory.

To configure the theme’s location, we must make the change outside of our theme. We will create a simple plugin that will go into wp-content/mu-plugins which get automatically loaded without requiring activation. I called mine modify-theme-path.php call yours whatever you want.

<?php
    register_theme_directory( ABSPATH . 'themes' );
?>

Now, WordPress will look in my root directory for a themes folder but will also continue to look in wp-content/themes as well.

Dwayne

Leave a Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • Thoughts on the Flipper Zero
  • Waiting for an Element to Exist With JavaScript
  • How To Paginate An Array In Javascript
  • Handling Errors with the Fetch API
  • How To Get Last 4 Digits of A Credit Card Number in Javascript
  • ChatGPT Stopping Part Way Through a Response? Here Is How You Fix It
  • How to Use Neural DSP Archetype Plugins With the Quad Cortex
  • How To Mock uuid In Jest

Recent Comments

  • CJ on Microsoft Modern Wireless Headset Review
  • Dwayne on Microsoft Modern Wireless Headset Review
  • CJ on Microsoft Modern Wireless Headset Review
  • john on Microsoft Modern Wireless Headset Review
  • Dwayne on Why You Should Be Using globalThis Instead of Window In Your Javascript Code

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz