Use the function flush_rewrite_rules() for set the rewrite rules new, but not with your code on init-hook, only on activation plugin or theme! See more in my post: http://wpengineer.com/2044/custom-post-type-and-permalink/
global $wp_rewrite;
$wp_rewrite->flush_rules();
Flush rules only on activation (and deactivation). Don’t do it on any other hook.
register_activation_hook()
Related Posts:
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- How to modify URL structures in custom post types and taxonomies or terms
- Help with a TV series Rewrite structure
- Permalink rewrite with custom post type and custom taxonomy
- How to check if last uri segment is a custom post type or taxonomy term?
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- Add hierarchical taxonomy to permalink for custom post type
- Permalink Structure CPT With Custom Taxonomy Fails
- Parent & Child Taxonomy slugs in custom post permalink
- Customize Custom Post Type URL
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- WordPress custom permalink and archive link for custom post type
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Parent cpt/child custom post type URL permalink relationship
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- Two Permalinks with one Taxonomy (custom taxonomy) and (custom post type -> custom taxonomy)
- Can a custom post type have a Parent Page?
- Rewriting a custom-post-type permalink with taxonomy term?
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- Remove slug in taxonomy url
- Taxonomy, Terms, and Template Files
- Is there a way to use regular categories with custom post types?
- Adding meta values to permalink
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Understanding Permalinks on Custom Post Types
- Prepend meta_value to permalink of post
- Rewrite permalinks for custom posttype and custom taxonomy
- Custom taxonomy & post slug permalink
- Including two taxonomies in a permalink structure
- Need help with complex custom post type setup
- Define permalinks for custom post type by taxonomy in WP 3.4
- Permalink Structure problem with cpt and custom taxonomy
- Custom Taxonomy List links being re-written
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Custom Post Types, Custom Taxonomies and Permalinks ?
- Custom post type permalinks giving 404s
- Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links
- What is better: Custom Fields vs Custom Taxonomies with Terms for perfomance, scalability and better user experience
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- how to get archive urls with same origin for custom types and terms?
- Programmatically adding posts
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- multiple url slug for single custom post type
- Custom post type and taxonomy permalinks – Structure
- Custom Post Type and Custom Taxonomy Permalinks
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Change Permalink Structure for Tag.php template
- Making a custom help center page
- Custom rewrite rule for hierarchical custom post type
- Custom post type url with category
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Removing custom post type slug from URL
- Custom taxonomy rewrite with query var returns %2F in URL
- Custom taxonomy returns 404
- permalink /category/post-name with custom post type and taxonomy
- Custom post type and taxonomy permalinks
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Rewrite rule for Custom post type Monthly and Yearly archive
- Custom post type Permalinks with hierarchical Taxonomies
- Properly flush rewrite rules on plugin activation
- Template files for Custom Post Type and Taxonomy
- Can’t use pagination with custom taxonomy
- Set parent for custom post type archive rewrite url
- Using page title as a link to term archive
- Custom taxonomy and post type rewrite rules
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Error 404 change permalink term custom term taxonomy
- Change CPT permalink to use the category
- Redirect Custom Post Type from Child Taxonomies
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Pretty permalink structure with multiple (AND OR) taxonomies
- Custom Post type and Taxonomy in post URL error
- redirect old post type url to new structure url
- How can I add a “fake” parent into the permalink?
- Multiple Custom Post Type permalink issue
- Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
- Custom post type child page 404
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- WordPress Custom Permalink Structure with Custom Post Type and Taxonomies
- Add taxonomy to custom post type archive
- Permalinks Works for Custompost type but not with pages Why?
- Problem with Custom Post Types, Taxonomy, permalink, Archive
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- What is the best way to relate different custom post types?
- Modify permalink of CPT archive to support two taxonomies
- Have Custom Taxonomy Slug Fall Under Custom Post Type Slug