You’ve highlighted the issue of creating custom post types in a theme rather than in a plugin. If the user changes to a new theme then you cannot rely on any functionality in the theme you have created.
Themes can add functionality, but in general should be concerned with the presentation of your site
Plugins will add functionality
Hence this is where I suggest you add the register_post_type code. The Registering Custom Post Types documentation recommends this approach as well, so have a good read through that for more detail.
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- WordPress 3.3 custom post type with /%postname%/ permastruct?
- Show Custom Taxonomy Inside Custom Menu
- Custom Taxonomy’s Label to change the text appearing in Appearance > Menu
- Have different search results template depending of custom post type searched
- Why does a custom post type need the ”hierarchical’ args setting?
- WordPress REST Create Post of Custom Type
- How do I programmatically add items of content to a custom post type?
- Created a custom post type- can’t view it
- Merging two Custom Post Types into one
- remove_action conditionally for Custom Post Type
- WP_Query pagination using only numbers instead of /page/1 on URL
- How do I set the content for a post of a particular CPT?
- Uploaded image not appearing in custom post type
- Custom Post Types – Titles as Taxonomies
- Custom post metadata not appearing in public API
- Using pre_get_posts to Filter Posts
- Parent page using wp_dropdown_pages and multiple post types
- Query for custom post type objects in a taxonomy and with a meta value
- Get post type from taxonomy or category page
- Add nonexisting pages to navigation
- How to add plugin custom field to custom post type?
- Multiple post type queries (with specific arguments for each)
- Is it possible to create a post using a metabox?
- How can I get_post_meta() in the most efficient way?
- related posts – pulling tags from a specific post type
- WP 3.0.5 – Custom posts matching 2 taxonomies
- Custom Post Type Loop within Shortcode
- How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?
- Custom Post Type – Display Categories & Tags In Dashboard list
- How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?
- How to add post_type=value when editing that post type in the WordPress admin?
- Change archive page template using pre_get_post
- Force documents to appear in Featured Image dialogue
- Publish an XML feed from a CPT with ACF fields?
- Custom post type redirected to homepage – how to debug
- Filtering WP_Query Dynamically on the Front-End
- How to retain $_POST data when submitting form to custom page
- custom taxonamy and post type
- retrieve Meta field value from CPT and set those values as Image Meta Field “Title”
- Taxonomy custom post type URL
- WordPress post_where & posts_join not working only for custom post type
- How do I display the taxonomy for a custom post type in an array
- WordPress custom post query with pagination
- When an unregistered user submits a form for a custom post type, send an email that lets them delete their post
- Multiple tag cloud filtering
- add_rewrite_rule and passing variables for custom post types
- Possible to filter custom post type with multiple meta data?
- Best way to organize book-page structure
- Adding custom image sizes and post types to a plugin or to a theme?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Custom templates for a specific category
- Three Most Recent Posts, One Per Term
- Display different information of a custom post type
- uploading problem of wordpress theme
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- How do you make a list and list item relation if custom post types?
- Two custom post types divided in two columns inside a bootstrap carousel
- Getting array_merge(): Argument #2 is not an array on register_post_type
- Is it possible to sort metabox teaxtarea values?
- How can I relate custom post types?
- creating files for displaying different custom post type posts with paging
- Sorting by meta_key different to search criteria?
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Save Custom Fields
- Custom post type posts wont show in wp_nav_menu()
- “Order” doesn’t work in custom loop?
- how can i add an array of post types to this query?
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- How do I set a post slug automatically based on taxonomy?
- Get a list of custom post type (property) when clicked on custom taxonomy 1 (rent or sale) from custom taxonomy 2 (city) page
- How to divide Subcategories into pages of parent category wordpress
- WP Query: If field X is empty, show posts based on field Y
- Is there any filter to add a custom attribute to the tag in admin panel?
- Display Posts that fit a certain criteria on Category pages
- How do I find out which (page) template file my custom child post is looking for?
- Custom post type category returns null
- Custom post type order by post_title
- Tell wordpress to show a single page instead of an archive page
- Modify Url for Edit Post Screen in Custom Post Type
- How to get post by meta value
- Post display in separate page [duplicate]
- Create dynamic logo carousel without using any plugin
- Delete Post by User
- Use Category for Custom Post Type – But Need Another Separate Archive Page too
- Custom post type translation
- Test for post type in request filter?
- What kind of post type structure do I need to manage a list of ranked skills?
- How to make post page unique and show it on home page?
- Have two (permalinks) urls for a same custom post type
- If taxonomy show class of active
- Custom Post Type Permalinks Problem
- How to loop through custom posts in admin edit screen
- Notices when submitting custom post type from front-end
- Custom Post Meta on a Different Page?
- wp_redirect to file:// location results in blank page/cannot be displayed page
- querying to custom field over ACF REST API
- Fatal Error WordPress Custom Post Type UI + WPML