You must call register_post_type
on each page load, when you register a post type it doesn’t modify the database it updates variables which only exist for that page load. If you don’t do this WordPress is unaware of that post type. Much the same way that you register settings pages and styles on every page load, WordPress doesn’t remember that you enqueued a stylesheet 5 pages ago, it needs to be told to load it.
It’s the same with post types and custom taxonomies. Even the default types of pages posts categories and tags are registered on each load.
As a side note, you should not flush rewrite rules on every page load, it’s an expensive operation and only needs to be done when things change, as rewrite rules are stored in the database.
Related Posts:
- Category as Class for Custom Post Type
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- current-menu-item class for custom post type parent
- Adding class to featured image
- different post-class when template is loaded via ajax
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- How to assign classes to all elements?
- How to change “post_class()” for a custom post type?
- Apply Post Class to Custom Post Type
- Add a class to post_class if more than one post shares same meta_value_num
- Correct way adding External classes to Custom Post type and output their methods to template
- Highlight a Post on archive page if it has a new comment?
- Change permalinks for posts but not for custom post types
- Sort custom post type list table by display name of a user id stored as post meta value
- Assign single template to multiple custom post types?
- Get posts based on meta key/value
- Search that will look in custom field, post title and post content
- Create a dropdown with Custom Post Types as option in admin
- How to list custom taxonomy categories?
- How to intercept publish post for a custom post type “event”
- clients list using wordpress
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Assign Page Template Within A Custom Post Type
- Custom post types not imported properly
- query order by date on custom type: wrong order
- Call different archive page based on post type
- Error after deleting Custom Post Type with a function (no trash used)
- Using posts and postmeta table to store custom Address Book Plugin data
- Change message given when deleting post from custom post type
- associate custom post type with tags with specific pages
- Posts navigation in custom post type single.php not working
- Custom WP TItle from custom template with dynamic URL structure
- Help with CPT template pagination
- taxonomy template for custom post type the same as the archive
- if custom posts type exists and there are posts load script
- Custom Post-to-Post with multiple parents?
- How to connect two custom post types with nested loops
- Order By Post Type ThenBy Taxonomy
- custom post type not showing in menu
- Query/list all terms and their custom post count
- How can I make a custom post type sticky?
- Get Taxonomy Term Title by it’s URL
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Limit number of custom posts per taxonomy
- How to change wp prefix for custom post type only?
- How to handle paged param in post and custom-post-type?
- Allow add new post access to custom post but not wp post for some role
- Blog posts for custom post type only
- Post Type rewrite rule to point to custom Page/template
- sub CPT and CRUD
- Warning after create Custom post type with Roots theme
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- How can I use archive-{post_type}.php theme template?
- Custom Post Type conflicting with page?
- How do I get the custom category URL from the custom post type?
- Associate all Custom Post Types with Taxonomy
- Custome fields not displayed
- wp-json API: not logged in when clicking link to the API from admin mode
- Custom Post Type for Shortcode Use – Prevent it display as a post (with slug)
- Custom post types, disable fields
- Custom Post Type Custom Archive Page Not Working
- Enabling permalinks disables custom page template
- Easier way to display custom post meta?
- pre_get_posts works in post type archive but not in single post
- Copying over taxonomy structure from one CPT to another
- Related “custom post type” using “custom taxonomy”
- How to create Custom Taxonomy Search Drop Down for specific Post Type
- Disable permalinks, but allow RSS feeds
- set_object_terms action hook based on the function in the published CPT
- Loop through items created in a custom post type
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- Changing CPT permalink
- Using wp_insert_post for one custom type inside another custom post types’s save function – big problem
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Custom post type and taxonomy same slug
- filter the title changed also the page titles
- Columns depending on posts count
- How to Show all Values in category.php page using post_type
- Decrement term in for each
- Add role privileges of the custom post type
- WordPress custom post type advise
- Custom Post Type and Taxonomies, creating the corresponding template file and loop the data
- Excerpts and Custom Post Types
- Capability to edit own post, but not create new one
- Why won’t this rewrite rule work?
- Custom post type single display is ommited
- How to not have the items of the subtaxonomy within the parent taxonomy
- Include Custom Post Type Archive in wp_list_pages
- “regular” pages not found after changing permalink
- How to save an integer as taxonomy term?
- One random post from multiple custom post types
- empty dashboard for custom role
- How to stream a linked file in WordPress
- Restrict editing of a custom post type based on status and user capabilities
- How can i change url structure of cpt like this?
- how insert how many post type in this function?
- Error 403 when posting comments to a custom post type from a different page
- Possible to limit internal link search to post types with Gutenberg editor?
- Complex Custom Loop with Includes