You have to register your post type before you flush the rules. Your init action doesn’t run on plugin activation, so your flush_rewrite method should call register_content_types first before flushing the rules.
Related Posts:
- Can a custom post type have a Parent Page?
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Permalink / Rewrite not working immediately
- CPT Template Not Showing – Getting 404
- add_rewrite_endpoint() not working for custom post type archives
- Adding meta values to permalink
- Permalinks so that one custom post type appears to be a child of another, not working
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- WordPress Custom Post Type Category Page
- How to Add Pages Under Custom Post Type URL Structure?
- Prepend meta_value to permalink of post
- How to check if last uri segment is a custom post type or taxonomy term?
- Pagination Doesn’t Work
- Rewrite custom post type url’s adding meta box values
- Permalinks using event date (year & month) instead of publication date
- Multiple parameters in a custom post type url rewrite
- WP Rewrite Rules – Custom post type & taxonomy
- Need help with complex custom post type setup
- WordPress monthly archive links result in 404
- Remove base slug in CPT & CT, use CT in permalink
- Rewrite rules for custom post type ‘attached’ to another custom post type
- Disabling post_type in URL
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- how to get archive urls with same origin for custom types and terms?
- Adding the taxonomy before the custom post type
- add_rewrite_endpoint() and Custom Post Type Archive
- Pagination problem
- Custom post type with slug for plural (archive) and for single
- add_rewrite_rule and how to get the custom post into the worpress loop the correct way
- Permalink Structure CPT With Custom Taxonomy Fails
- Rewrite WordPress URL to show CPT meta field data
- Custom Post Type won’t Register
- Making a custom help center page
- Custom rewrite rule for hierarchical custom post type
- Rewrite and custom post type: order by custom field not working
- Am I using the flush_rewrite_rules function in the right place?
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Adding Post id to the end of slug in a Custom Post Type
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Customize Custom Post Type URL
- Custom taxonomy rewrite with query var returns %2F in URL
- cpt and page sharing same base permalink
- Hide or disallow default custom post type url?
- A case for Hierarchical Custom Posts
- Rewrite CPT child page URL to support query var
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Best structure / rewrite rules to achieve the following url
- Relationship between set rewrite flag in register_post_type and add_rewrite_rule
- Custom post type paging 404 error
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- Combine multiple CPT names to create valid permalinks
- Custom Post Type – Rewite Archive page
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- How to rewrite the post slug of a custom post type post
- rewriterule not working
- Custom post types and custom variables — add_rewrite_tag() not working
- Add Custom Values to Permalinks Through Custom Fields and Posts
- Why do I need to register my custom post type a second time when flushing rewrite rules?
- Custom post rewrite rule not working
- Subpages Permalinks Issues
- rewrite rules hierarchical
- Rewrite rules for custom post type
- Custom taxonomy and post type rewrite rules
- WordPress rewrite rule doesn’t work unless post category is explicitly called in regex
- Url Rewriting a dynamic wordpress page with parameters
- How to make a post accessible from multiple post type slugs?
- Rewrite URL for CPT to domain/post-name/post-id
- Custom Post Type add_rewrite_rule
- How to apply multiple rewrite_rule to a single custom post type url?
- Custom permalink structure for custom post types including multiple taxonomy
- Sudden 404 pages on product category archives
- CPTs relationship
- Change CPT permalink to use the category
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- Rewrite url for custom post type with specific url
- Two CPT: one is using part of the custom rewrite slug from the other
- Custom taxonomy archive slug overwrites static page
- Group based routing and administration
- Adding Custom Taxonomy Along-with Post Name in Post Type Permalink
- how to use two permalinks for one custom post type based on categories
- Get the custom post type slug but remove the rewrite prefix?
- Custom Rewrite Tag Structure
- Parent cpt/child custom post type URL permalink relationship
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- CPT Template Not Showing – Getting 404
- What is the proper way implement a global $wp_rewrite?
- Permalink of Custom Post Type
- Ideal top-level slug methods
- add_rewrite_rule not working in Custom Post Type UI Plugin
- add_rewrite_rule not working with custom post type
- Url rewrite with custom post type and taxonomy
- Paginate yearly archives for a custom post type
- Custom archive URL as a subfolder of the custom post type slug
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Two Permalinks with one Taxonomy (custom taxonomy) and (custom post type -> custom taxonomy)
- What is the best way to relate different custom post types?
- How to change rewrite slug for custom post type without conflicting w/ child pages of page with same slug