Skip to content

Instantly share code, notes, and snippets.

@marcwieland95
Created August 21, 2018 07:30
Show Gist options
  • Save marcwieland95/52dc4045b72bc464364c2f457e73464c to your computer and use it in GitHub Desktop.
Save marcwieland95/52dc4045b72bc464364c2f457e73464c to your computer and use it in GitHub Desktop.
add_action('generate_rewrite_rules', 'themes_dir_add_rewrites');
function themes_dir_add_rewrites() {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;
$new_non_wp_rules = array(
'styles/(.*)' => 'wp-content/themes/'. $theme_name . '/styles/$1',
'scripts/(.*)' => 'wp-content/themes/'. $theme_name . '/scripts/$1',
'images/(.*)' => 'wp-content/themes/'. $theme_name . '/image/$1',
);
$wp_rewrite->non_wp_rules += $new_non_wp_rules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment