You can use templates located within your plugin instead of theme files, like so:
add_filter('archive_template', 'redirect_to_plugin_archive_template');
function redirect_to_plugin_archive_template($template) {
if(is_post_type_archive('my_cpt')) {
return dirname(__FILE__) . '/templates/my_archive_template.php';
}
}
add_filter('single_template', 'redirect_to_plugin_single_template');
function redirect_to_plugin_single_template($template) {
if(is_singular('my_cpt')) {
return dirname(__FILE__) . '/templates/my_single_template.php';
}
}
Obviously you need to change the custom post type slug and the template paths, but that’s the general idea.
Related Posts:
- Custom comment type maybe?
- How to load a new template page according to a particular URL?
- Updating post meta for custom post types
- Themes VS Plugins [duplicate]
- I need to add a custom “cover” to every new post — plugin or custom setup?
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Redirect to another page using contact form 7? [closed]
- How display specific category post to specific users?
- Custom Post Type, Custom Columns List
- Check if theme supports sidebar
- Adding category base to url in custom post giving 404?
- Adding LOAD MORE on a page
- Ultimate Members Default Post Layout problem
- Cannot view Custom Post Type no matter what I try
- Creating custom “player-objects”
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- Proper Way to Modify Plugin
- How to edit a wordpress plugin without break its update process
- How to get a variable number of posts per post type on the main loop?
- Looking for a Table of Contents (TOC) plugin for WordPress
- WordPress Plugin Development In MVC Architecture, How?
- Where should I use get_option in a plugin
- GPL and plugins
- Disable Specific Widgets on Selected Pages of a WordPress Website?
- Create page when plugin is activated
- How to show custom message once on plugin activation?
- Post source link plugin – small modification
- How to add users roles dropdown in registration in wordpress
- wp_schedule_event / cron_schedules – custom recurrence time not working in Plugin
- Add .html extension to custom post type taxonomies
- WordPress network: set themes and plugins for new blog
- How to get the custom page get_permalink?
- Remove POST_TYPE from custom post type permalink
- How to edit plugin’s html? [closed]
- Custom Post Type causes Page Not Found
- Can a plugin add to header/footer/body content?
- Organising the plugins folder in wordpress
- force customers to add only single item to card per purchase EDD [closed]
- Preventing BFA in WordPress without using a plugin
- Output HTML only on individual post view
- Manually add order item with fixed product_id in WooCommerce
- ‘Customize’ button in admin bar for CSS
- Auto delete WordPress users according to time
- Saving Custom Post types and fields to a custom table
- Building a store locator with google maps
- How to show Recent Page instead of Post?
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- How can I create a custom shortcode that will return a custom post type by ID?
- How would I go about creating a user ranked post popularity page?
- All of my custom posttypes are 404’ing
- ‘No Results Found’ on single post for custom post type
- Making a Template for a CPT created by a plugin
- External Domain on WordPress Multisite
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Customize The Events Calendar to Include an Option to Expand for More Events Listings
- changing posts layout in ultimate member profile plugin
- Custom setup of wordpress comments that are displayed
- How do i get file_get_contents to work in wordpress
- Plugin Development – Functions or Hooks?
- Add filter on html tags,attributes on specific function in wordpress
- Overriding an Array in a Plugin’s Class/Function from functions.php
- Change Header (Logo) Based on Login
- Add custom columns in custom post type browse page
- Preview with Custom Post Type Not Working
- How can i summerize posts or news automatically in word press site?
- wp_mail – using a custom field value
- Custom Post Type template for homepage
- Edit page header on a custom plugin
- How to fix these PHP Warnings with the “Feed JSON” plug-in?
- Custom content plugin for front page in wordpress
- Best method of implementing compartmentalized custom post types on a multi-site network
- How to search post titles with whole words only, but not the exact word only?
- How to hide featured images of all posts falling under the same category in wordpress?
- Remove custom taxonomy name from the slug – Custom Post Type UI
- custom post type get_posts() function not work
- Create multiple posts when a custom post is created
- Making a list that can be filtered by category/tags
- how to change a static testimonials into dynamic
- Rename a folder via HTML POST request
- How can I add a custom Javascript snippet to display my feedback in footer?
- My wordpress local urls is still displayed even moved to live
- working code, not working – Plugin Dev
- Custom shortcode being shown in WPBakery backend rather than the block
- Issue calling my functions on Plugin activate in WordPress
- User upload dashboard
- How to restrict the user from viewing comments but with option to write comments?
- Create dynamic / data driven pages in wordpress
- custom/automatic export function – one post at a time?
- Custom SportsPress list
- How to restrict “too soon” downloads with a general rule?
- Display Powerpress media url
- Hide some shortcodes on posts from back-end
- Custom Post type plugin breaking the front page shows dashboard?
- How can i do custom author list?
- Add a filter to a different custom plugin
- Child Plugin Admin Panel
- Looking for a plugins for organization portal (Staff, Units, Departments)? [closed]
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- How to disable plugin capability : “create new category”
- How to make content as required in custom post type?