Skip to content

Instantly share code, notes, and snippets.

@a7madev
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a7madev/8b3cef79edc985e1a9f8 to your computer and use it in GitHub Desktop.
Save a7madev/8b3cef79edc985e1a9f8 to your computer and use it in GitHub Desktop.
WordPress - Rewrite Root Rules
/**
**================================================================================================================**
* Rewrite Root Rules
**================================================================================================================**
**================================================================================================================**
**/
add_action('generate_rewrite_rules', 'roots_add_rewrites');
function roots_add_rewrites($content) {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;
$roots_new_non_wp_rules = array(
// '(img|js|css|fonts)/(.*)' => 'wp-content/themes/'. $theme_name . '/$1/$2',
'(?:\/)?[a-zA-Z\d\/]*?\/?(img|js|css|fonts)\/(.*)' => 'wp-content/themes/'. $theme_name . '/$1/$2'
);
$wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment