Rewrite Rules for Multiple (more than 2) Taxonomies

You could try something like this: function custom_rewrite( $wp_rewrite ) { $feed_rules = array( ‘product-category/(.+)/material/(.+)/color/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_material=”. $wp_rewrite->preg_index(2).”&pa_color=”. $wp_rewrite->preg_index(3) “product-category/(.+)/color/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_color=”. $wp_rewrite->preg_index(2) “product-category/(.+)/material/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_material=”. $wp_rewrite->preg_index(2) ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( “generate_rewrite_rules’, ‘custom_rewrite’ ); It … Read more

How-to add rewrite rules to point the uploads folder to a subdomain

If you are not willing to filter only image uploads, i.e., all uploaded media will reside in the same folder/subdomain, then there’s a simple configuration solution: go to options-media.php set the Store uploads option to wp-content/uploads set the Full URL option to http://uploads.yourdomain.com create a subdomain making the uploads folder be http://uploads.yourdomain.com

External/non-WP rewrite rules

Here are some notes. Install Toschos rewrite plugin Install Jan Fabrys rewrite analyzer plugin. Use the Rewrite API Add your rules to top. There’s also the function add_external_rule(), which should be accessible via $GLOBALS[‘wp_rewrite’]->add_external_rule(); All your external rules are accessible via $wp_rewrite->non_wp_rules. Here’re the internals, that show you how the rules get added inside $wp_rewrite->mod_rewrite_rules(): … Read more

Clash of the rewrites

Your best option is to register neighborhoods as a custom taxonomy and use that instead of categories. In your theme’s functions.php file, you just need to add: function neighborhoods_init() { // create a new taxonomy register_taxonomy( ‘neighborhoods’, ‘post’, array( ‘label’ => __( ‘Neighborhoods’ ), ‘hierarchical’ => true ) ); } add_action( ‘init’, ‘neighborhoods_init’ ); Next, … Read more

Rewrite default post type

Use the field in the admin Settings > Permalinks page to set your permalink structure to /blog/%year%/%monthnum%/%postname%/. To prevent custom post types from inheriting the post permalink structure, set with_front to false in your register_post_type arguments for all custom post types. Version 4.4 also added the register_post_type_args filter to allow modification of post type arguments … Read more

Custom rewrite rules for pages

The pattern WordPress uses to recognize pages is (.+?), which will match anything, but is not greedy, so it allows you to put something at the end. The following code works for me in WordPress 3.0.1: it places the extra pattern at the second-to-last place of the list, because the final pattern is so generic … Read more