There are other factors that you’ll discover along the way, but basically it boils down to: move all that’s CPT related from your theme’s functions.php to a plugin file.
Create a PHP file, put the plugin’s header information, add to the plugins folder, activate.
Now, you separated appearance (theme) from functionality (plugin). Here are two fundamental Q&A’s here in WPSE:
And here a related blog post.
You’ll find many examples of plugin-development in the site archives.
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Plugin: Where Do I Put The Template?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Creating a Custom Post Type as a Plugin? Why?
- Quick edit screen customization
- Mini-Site Strategy
- Render a different post/template from within the template_include action?
- Unable to filter on field on edit.php page
- Custom Taxonomy and tax_query Issue?
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Custom role capabilities to administrator not taking effect (no plugin)
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- How to append element after thumbnail
- How could I create a ‘private comments’ section on a custom post type?
- handling csv data with a custom post type
- Issue with pre_get_posts on custom post type archive pages
- Detect where custom post type is declared
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Insert Multiple Post with Same Publish Button
- get_object_taxonomies() returns empty array for custom post type
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- Unable to get Custom Plugin Options data
- What is the best practice for displaying my plugin content in themes?
- Add Custom Post type menu to another menu in specific location
- custom comments form for custom post type
- Custom fields for custom post type
- When should I create custom post types?
- Custom post type’s extra fields – how to handle?
- Save Multiple Metabox values
- Main query not querying any posts in custom taxonomy template
- How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data
- post_parent in custom post type
- What’s an efficient way to change the post status of many posts at once?
- Dynamically insert code to custom post type loop
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- How exclude or skip post type with get_next_post_link
- How do I add custom HTML to the content of an archive page’s posts?
- How to add query args to links to CPT admin submenu
- How to add and display custom content that is not a post
- Problem with adding custom post type meta to header by plugin
- Creating alternate meta box context locations
- Create a select metabox that the user can pupolate?
- Types plugin custom post add_action hooks
- Limiting Amount of Posts in a Custom Post Type again
- Limit Amount of Pages users can create in Custom Post Types
- Not Able to Add New Class To CPT Attachment Image
- Wp Meta Query does not work while simple Query Works
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- Orderby custom fields is not working
- Why are custom taxonomies only appearing on the edit page of one of these types, but not the other?
- How to stop the custom post type URL from the google search?
- How to add a default predefined thumbnail when creating a brand new post?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Plugin Development using classes – Public & Private Callbacks
- URL issue retrieving Custom Post Types using Backbone JS API
- WordPress Custom Post Loop
- Create a post automatically if search result has zero results
- Changing CPT permalink
- Correct way adding External classes to Custom Post type and output their methods to template
- Get all posts by many custom post types
- ‘Simple’ Reservation System
- Warning , Use of undefined constant PLUGIN_PATH?
- Custom Post Type Front Page Gives 404
- Show Post columns to specific users on condition
- Error when moving custom post type to bin
- Admin metabox with custom post type dropdown option not update choosed input after saving
- Having issue on Loading Meta Data From CSV to CPT
- custom data model – link and populate from admin backend
- Custom Post type plugin is using theme single.php and style.css
- get_permalink() of page the enclosing page not posts
- Run query on specific admin options page and send results to select field in another function
- Not able to get all the actions (View, Edit, Quick Edit, Trash), and not able to delete post in custom post type
- php output of generated custom metabox
- call a function when insert and update a custom post type
- Can’t save custom post type fields
- WP_Query doesn’t accept Category ID
- Error in WP Query. If variable is empty it is displaying previous post value
- Custom post type not being pulled in widget
- Registering an optional custom post type from a plugin
- Shortcode error
- Generate custom RSS from a plugin
- Issue on Counting CPT’s Under Taxonomy Term
- Get term_id for each instance of custom taxonomy
- How to internationalize the sub menu name “categories” in Custom post type?
- Add Excerpt On Quicksand Plugin
- Creating a Custom Post Type as a Plugin? Why?
- Inserting into WP DB
- WordPress Roles
- Create settings page to enable or disable CPT
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Custom Post Type urls not working
- get_post_types() is returning null
- I want to show a list of posts under specified categories
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs
- Redirect to All Custom post types
- Redirection after saving a post
- How to fix post_tags not showing for a CPT in new post for a custom user role?