Created
August 21, 2018 07:30
-
-
Save marcwieland95/52dc4045b72bc464364c2f457e73464c to your computer and use it in GitHub Desktop.
Theme based rewritte - https://www.hongkiat.com/blog/wordpress-url-rewrite/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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