How do you permanently remove default rewrite rules from the wp_options table?

Rather than modifying stored rules it would be more reliable to modify rules before they are stored. flush_rewrite_rules() calls WP_Rewrite->flush_rules() WP_Rewrite->wp_rewrite_rules() WP_Rewrite->rewrite_rules() Inside last there are fitting hooks to modify rules (after which result they will be saved as usual on each flush): do_action_ref_array(‘generate_rewrite_rules’, array(&$this)); $this->rules = apply_filters(‘rewrite_rules_array’, $this->rules);

How to map permalinks with accented letters to sanitized slugs?

The best way to accomplish this is remove the default sanitize_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of using accents in permalinks. Example: remove_filter( ‘sanitize_title’, ‘sanitize_title_with_dashes’); add_filter( ‘sanitize_title’, ‘restore_raw_title’, 9, 3 ); function sweURLtoCHAR($text) { $url=array( “%C3%81″,”%C3%A1”, “%C3%8D”,”%C3%AD” ); $char=array( “Á”,”á”, “Í”,”í” ); $str = … Read more

Permalink rewrite with custom post type and custom taxonomy

You have to build up the link structure by using filters post_link and post_type_link: add_filter(‘post_link’, ‘territorio_permalink’, 10, 3); add_filter(‘post_type_link’, ‘territorio_permalink’, 10, 3); function territorio_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, ‘%territorio%’) === FALSE) return $permalink; // Get post $post = get_post($post_id); if (!$post) return $permalink; // Get taxonomy terms $terms = wp_get_object_terms($post->ID, ‘territorio’,’orderby=term_order’); if (!is_wp_error($terms) && … Read more

Categories’ hierarchy in URL

The permastruct /%category%/%postname%/ will include the categories and subcategories in the URL from top to first assigned child. So, if you want the URL be site.com/source/books/moby-dick/*postname*, you have to assign the post only to “Moby Dick”. Assigning the post only to “Moby Dick” category will still show the post under “source” and “books” category archives … Read more