The new permalink structure is only saved when WP_Rewrite::flush_rules()
is called. Because this is an expensive operation (calculating the new rules and saving them to the database), you should not do it on every init
call, but only when you change the structure. The custom post type however must be registered at every init
call, since it is saved in a PHP array in memory, not in the database (which is why it forgot the custom post when you switched themes: the permalink structure still existed but referred to a custom post type that was not loaded, giving an error).
Related Posts:
- Is there a flowchart for WordPress loading sequence?
- How do register_sidebar() and get_sidebar() work together?
- Multiple WordPress sites with docker
- .maintenance and maintenance.php also in multisite install?
- Is it possible to change the attributes of a registered style or script before it fires?
- Is there a plugin to make attaching images easier?
- how to change “published date” format on edit.php (Posts page)?
- Custom category order with get_categories
- How to change submit button value in comment from “Post Comment” to “Send”
- Pagination Help on Crazy Custom Authors Page
- Getting rid of the #038; when string replacing content
- Querying multiple WordPress custom fields with AND qualifier
- Change “logged in” link in (you must be logged in to post a comment)
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Comment filtering (search)
- What Is The Difference Between suppress_errors() And hide_errors() in $wpdb?
- On Install, which code sets the ‘home’ option?
- How to find if a post with custom_field == X exists?
- Display a default image for custom-logo
- WP_Widget Deprecated
- Customizer: How do you add HTML to control labels?
- Extract & Display the REAL first image attached to a post – extend the_post_thumbnail()
- Stopping People Viewing Draft Posts
- Style reset password page? /wp-login.php?action=rp
- Customizing the default logout page of WordPress
- Custom column under All Users (multisite network admin)?
- add_rewrite_rule won’t work
- How To Add buttons to the toolbar which appears in TinyMce when you click over images
- Last time a user logged in
- WordPress equivalent to Drupal Views? [closed]
- Posting as different users
- show the meta values to visitors that collected via coment form
- Make wordpress generate a custom XML file(not a sitemap) that is updated only when new content is posted?
- How did I enable atom feeds in a fresh WP3 install?
- Hide editor with specific post meta value
- Custom URL going to 404
- WordPress slugs and 404 handling takes preference over folders in site root?
- Suggestions for Implementing a Wedding Website in WordPress?
- Add a date updated/date modified option using custom fields
- How to wrap the list with custom class using wp_nav_menu?
- Custom search to display results within same page
- How do I change .css versioning?
- Get ORIGINAL image links from get_post_gallery
- change url for static files in /wp-admin with a cdn url
- Save title as custom field on custom post type
- Qtranslate + Woocommerce (multiple tinymce) [closed]
- CSS Customizations for certain page
- How can I have a common background color across multiple WordPress blocks?
- My custom sql query for getting a username giving me a warning and an error
- Get Custom Taxonomy Terms by Date
- Semi complicated custom taxonomy question
- Archive subtitles for different types of archives
- Point homepage to custom php page
- Duplicated content with custom shortcode
- Display a list of subcategories (from specific Category) a post belongs to
- Implement a Walker with custom object rather than WordPress database object
- Adding tags when creating new post
- How can I tag a menu item as visited for each unique user?
- Display posts by combining multiple meta key
- Custom Content Page
- Add Member’s birthdate from Backend and shows it on frontside [closed]
- How to add active state to the navigation links?
- How to add functionality to an existing theme (using child themes)
- How to Render Post Types in RSS Feed?
- How do I fix my static page
- URL and Site title outputting on Login page
- 404 when Previewing an unsaved draft
- List of contents of entire blog
- Display a specified content on a Page and all its child pages
- optimal taxonomy or custom post types
- Custom field not editable by the user
- WordPress category custom title
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- Use a custom page with dynamic content as a user profile page
- adding fade on mouseover to images
- Customize section does not show my widget areas
- Invitation link to a site in multisite network does not work?
- Add helper text in custom-header section in admin
- How to edit content in code view of home page when there is some theme applied?
- How to display strikethrough text in button text (for special offer)
- Lightbox not showing image caption
- WordPress core jquery version file not loaded?
- Can we add an extra button on woocommerce shop page and use it to send the product info including image in a mail?
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Add a custom intro page
- clickable toggle menu, help
- How to change custom link of subpages from of localhost to website
- twenty seventeen customizer duplicates section content
- How to append the excerpt to the content in the single post page?
- How to Password Protect whole site except for some subdirectories
- Custom dropdown search form that allows users to select option B based from Option 1
- Ordering a specific post type
- Header image doesn’t show up on page
- How to get name and email value from a custom form and add it to campaign monitor subscriber list?
- Custom Link In WordPress Media “Attachment Details” Upload Screen
- “Static” pages within a theme
- Assign classes to Custom fields
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Prevent posts from being published if the ‘Uncategorized’-category or no category is selected
- Post interior margin in twenty eleven theme