After custom post type registration, that is register_post_type()
, try adding function flash_rewrite_rules();
This will automatically flush all rewrite rules so you won’t need to go to permalink settings each time.
See this page: https://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation
Example:
add_action( 'init', 'my_cpt_init' );
function my_cpt_init() {
register_post_type( ... );
flush_rewrite_rules();
}
As it’s said in the docs, it’s better to do that on plugin activation.
Related Posts:
- How to Add Custom Taxonomy To Woocommerce Plugin
- Prevent trash/delete action on specific post types
- How to add custom content template part for a custom post type on main query using a plugin
- register_taxonomy with multiple object type and update_count_callback
- How often do you need to register_post_type?
- How to use a dedicated template for the Custom Post Type from a plugin?
- Remove POST_TYPE from custom post type permalink
- How to register custom post types in a plugin?
- How to append element after thumbnail
- How to have the right design for a custom post type without accessing themes
- Custom Post Type | Fatal Error on register_post_type()
- Set object terms not working on plugin activation
- custom post type not showing in menu
- Adding a custom post type taxonomy template in plugin
- Addition of custom option panel crashes Media Library & Admin Area
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Custom fields for custom post type
- ACF in wordpress
- post_parent in custom post type
- Unable to format dates to put in event calendar
- Custom post type in Custom widget – $listItem
- Validate Custom Post Type fields
- Types plugin custom post add_action hooks
- how can i show a google map in custom post type
- Restrict Custom Post Type to One Item
- Custom Post Type Front Page Gives 404
- Show Post columns to specific users on condition
- Insert custom taxonomy into category query
- Run query on specific admin options page and send results to select field in another function
- Custom post type that lets users create a set of posts?
- Can’t save custom post type fields
- get_post_types doesn’t work in plugin
- Add Excerpt On Quicksand Plugin
- Custom Post Types in plugins?
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to custom post type?
- Redirect after deleting post and keep track of pagination
- get_edit_post_link() not working as expected when passed id in plugin
- Date query for a custom meta field
- WordPress metabox file upload in custom post [duplicate]
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- WordPress custom post action hook
- Uploaded image not appearing in custom post type
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- Dynamic Custom Post Type Plugin
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- Get all of user’s custom post types in WP Admin for plugin
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Custom Post Type: Upload Multiple Images
- Orderby CPT custom fields not working
- Use custom metabox to update automatically a post after a given date
- Send notifications to custom post author when custom post is edited
- Custom Post Type + Categories
- Shortcode for CPT post content in a page
- To use custom post types, or not to use
- Autocomplete or suggest from post titles inside plugin
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- Pods CMS: How to add custom column to Adnvanced Content Type
- How do you make a list and list item relation if custom post types?
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- Is it possible to sort metabox teaxtarea values?
- Custom Plugin – Query CPT – Display Results
- Modify a plugin function output from another plugin
- Custom rewrite rules for /pastissues/%category%-%postname%.html
- Content in WP Editor displayed below CPT shortcode [duplicate]
- restricting custom rewrite to just one custom post type
- Change Text in Admin Panel
- Custom Endpoint For Specific Custom Post Type
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to display the post using a shortcode in WordPress?
- Custom post type specific item design
- Issue removing columns from admin table
- Shortcode and get_template_part
- dynamic vue widget inside custom post
- WP REST API Custom endpoint don’t work in my plugin
- Custom Post Type single post type shown in theme single.php
- how to allow subscriber to add/edit/delete custom post type
- Include images from pages in wp search.php results in default wp search
- Populate metabox dropdown with post title from another Custom Post Type (issues with wp_reset / global $post)
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- Enable shortcodes on custom post type
- Custom meta box in editor of custom post type not working
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Display subcategories in the filter on CPT
- Remove Custom Capability
- Can I override the permalink/slug on creation
- call_user_func_array() error after moving to another server
- Plugin Error on activating
- Custom Taxonomy Showing in WP Menu
- Issue on Adding Taxonomy to Custom Post Type Using Function
- How to apply order on custom taxonomy and custom meta key on custom post type
- Hide custom post type and use its slug in new plugin menu
- Plugin – read post into blank page [duplicate]
- Is an Office a custom post type [closed]
- Woocommerce product page is not showing custom css [closed]
- How to change post cpt with submit button?
- Custom Post Type featured option
- How to provide page_template path in custom plugin using WordPress