I have a plugin that adds a custom post type for a website I'm building. I am using the_content filters to change how a singular page looks, and it works great, allowing me to keep everything contained in the plugin.

However, I want to render a custom archive page using dls and what not, but I have no idea how to do this. This website will probably always use the same theme, but I still want to keep my plugin as separated from the theme as possible.

1 Answer
1

The archive-{post-type}.php files goes directly in your theme directory. Notice that you will also need to make sure has_archive is set to true for any post types you wish to display as archives. Depending on how you registered you post type the method used to change this might differ. I'm really just familiar with registering manually using register_post_type, in which case you simply need to include 'has_archive' => true in your arguments array, but I would suspect the corresponding functionality to be available in most post type related plugins.

I wanted to avoid creating a file that went in the theme directory, based on some advice here that if it's functionality you'll miss if you switch themes, it should go in the plugin. I'd like to keep everything in the plugin itself instead of dividing code between the theme and plugin.
–
Brandon WamboldtJan 30 '13 at 13:43

Sorry, I realize now I did not read your question carefully enough (or did you edit your question?). However, I could not agree more! I try to always keep code adding functionality in plugin, and let the theme manage layout and styling alone. I think you might be able to achieve what you want using load_template run from an init hook, or alternatively, using a theme with loots of hooks (e.g. mytheme_archive_loop or something) to let your plugin inject data at appropriate locations.
–
SimonJan 30 '13 at 15:04