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 do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- Customize permalink when creating a post
- Custom Taxonomy Not Showing in Menu
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- Using custom page templates with plugin [duplicate]
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- GravityForm: Populate Dropdown with custom post type [closed]
- Get all of user’s custom post types in WP Admin for plugin
- how to add extra meta box or textarea into custom post types
- Issue with pre_get_posts on custom post type archive pages
- Custom Post Type Navigation on Custom Field
- Plugin translation not working apart from name and description
- Get rewrite slug of custom post type in template
- “add_post_type_support” with Custom Post Type & ACF
- Shortcode insertion in tab
- Custom Post Type rewrite
- Admin notice not displaying
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Can’t get order_by meta_value_num to work properly
- How to quickly reorder posts in the admin panel that will persist for the wp-api
- Custom Post Type: Upload Multiple Images
- Add CPT as subpage under custom page
- WooCommerce product search titles only
- check if post title in a custom post type exists in page
- Detect where custom post type is declared
- Metadata for a taxonomy – is there any WordPress way of doing this?
- How to hack YARPP plugin to find related posts for custom post type?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Hook to override title, image and content
- Insert Multiple Post with Same Publish Button
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Update menu when saving settings
- get_object_taxonomies() returns empty array for custom post type
- One-to-many post relationships that are displayed by category (using posts-to-posts plugin)
- WordPress theme custom capabilities not works
- How to retain $_POST data when submitting form to custom page
- No posts found – Custom Post Type show_ui
- Why get_posts() not returning only selected category posts from Custom Post Type?
- single-{cpt}.php ignored
- If post has custom field then display css-class
- How to customize a permalink (URL) structure?
- Plugin: register custom post types, child ready and performance best practices
- How to add a custom taxonomy to show up in a custom post type menu?
- Replace text in post from cvs
- Insert and then update post_type by wp_update_post
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- add category name to permalinks on product page /category-name/product-name
- How can I make a custom post type sticky?
- Is it possible to create Custom Post plug-in?
- Give a permalink to Custom Post Types without title
- Getting template_include to work when allow_url_include is off?
- WordPress post_where & posts_join not working only for custom post type
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- WordPress multiple custom post types capability conflict in a single menu
- Getting meta in editor plugin, and event triggering issue
- Orderby CPT custom fields not working
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Unable to get Custom Plugin Options data
- Making a Template for a CPT created by a plugin
- Update post meta not working in transition_post_status
- Use custom metabox to update automatically a post after a given date
- Action or Filter Hook for a Custom Importer
- How to set a CPT to have a page as a parent, then rewrite urls accordingly?
- Broken featured images are uploading from frontend