• Hi,

    got a question about filtering url rewrite rules.

    I’m implementing a music-oriented website on WordPress, and got posts in the following categories:
    * Concerts
    * Venues
    * Blog

    I want different rewrite rules for each category, eg:
    * /concerts
    * /concerts/2007/12/09/concert+post+title
    * /venues
    * /venues/venue+post+title
    * /blog
    * /blog/2007/12/09/blog+post+title

    Note that no date is displayed for venue posts.

    Any help on how to implement this in WordPress is highly appreciated.

    These pages contains some information on implementing custom rewrite rules, but I can’t find the exact information I’m looking for:
    * http://codex.ww.wp.xz.cn/Function_Reference/WP_Rewrite
    * http://codex.ww.wp.xz.cn/Custom_Queries#Permalinks_for_Custom_Archives

    Regards,
    Vegard

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vsandvold

    (@vsandvold)

    So far I tried the following, without getting what I want:

    add_filter('rewrite_rules_array', 'my_rewrite');
    function my_rewrite($rewrite) {
    	global $wp_rewrite;
    
       	$category_rules = array(
            	'concerts/' => 'category/concerts/',
            	'venues/' => 'category/venues/'
        	);
    
    	$concert_post_structure = $wp_rewrite->root . "concerts/%year%/%monthnum%/%day%/%postname%/";
    	$venue_post_structure   = $wp_rewrite->root . "venues/%postname%/";
    
    	return ( $rewrite
    		+ $category_rules
    		+ $wp_rewrite->generate_rewrite_rules($concert_post_structure)
    		+ $wp_rewrite->generate_rewrite_rules($venue_post_structure)
    	);
    }

    Thread Starter vsandvold

    (@vsandvold)

    What I get is this:
    * concerts/ and venues/ don’t work
    * concerts/year/month/day/postname shows all concerts, what I would like concerts/ to do
    * Same for venues/

    Thread Starter vsandvold

    (@vsandvold)

    Any help is appreciated, guys.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘conditional rewrite rules’ is closed to new replies.