When a plugin is activated, the only thing that runs on that activation request is the activation hook. whatever you’ve got hooked to init has not and will not run on that request, so you need to register it in your activation before you flush rewrites. it’s only after the plugin is activated, on the next request, that the init action fires for that plugin.
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?
- Marking future dated post as published
- 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
- When we register a custom taxonomy or post type, does the WP database modified at all?
- 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
- 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
- single-{post_type}.php is not loaded despite flushing rules
- Custom Permalink Tag breaks Pagination
- how to get archive urls with same origin for custom types and terms?
- Rewrite numeric ID parameter for hierarchical custom post type
- Best action hook to create custom post and assign taxonomy terms to it on plugin activation?
- 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
- Specific routing for CPT
- Best structure / rewrite rules to achieve the following url
- Relationship between set rewrite flag in register_post_type and add_rewrite_rule
- Custom Rewrite Rule for Custom Post Type with URL Param
- WordPress custom slug rewrite
- 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
- Custom post rewrite rule not working
- 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?
- Custom Post Type add_rewrite_rule
- Sudden 404 pages on product category archives
- Change CPT permalink to use the category
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- Redirect Custom Post Type from Child Taxonomies
- Pagination URL in Custom Content Type
- Custom post type rewrite and wp_pagenavi interfering with each other
- Custom taxonomy archive slug overwrites static page
- Group based routing and administration
- Adding Custom Taxonomy Along-with Post Name in Post Type Permalink
- redirect old post type url to new structure url
- 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
- Custom post type rewrite with_front
- 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
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- add_rewrite_rule not working in Custom Post Type UI Plugin
- CPT Archive Pagination – Page not found
- 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
- 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