I am working with a multisite setup and I have created some custom post types, which seem to work fine except when trying to view any of the post types pages on the front end, I get a white screen. After looking into the issue it seems that flush rewrite rules fixes it. The problem with this is that admins wont have access to the permalinks setting so they cant flush it themselves.
I am currently using the following code to flush when activating a theme, but this is not ideal since a user will have to switch to another theme then switch back to the primary theme. So Im trying to find a way to modify the following code to work when a new site is made, thus having the custom post types working from the start. ---
/* Flush rewrite rules for custom post types. */
add_action( 'after_switch_theme', 'bt_flush_rewrite_rules' );
/* Flush your rewrite rules */
function bt_flush_rewrite_rules() {
flush_rewrite_rules();
}
Any help is appreciated, thanks.
UPDATED
I have a main site that users sign up on the front end for a site like such mysite.com/theirsite. The default theme for them is set. Thats where Im trying to place the code so flush rewrite works when they create a site, not switch theme. Admin dashboard is simplified so they dont have access to permalinks or theme -> editor.
I would think though that when creating custom post types, it's suppose to flush rewrite, thus not even needing to use the extra code?
If it helps this is my register post type code --