Working with wordpress plugin and theme templates structures

This is probably totally off the wall, but I want to create a new wordpress plugin, that will have its own subset of templates and pages. Whats the best way to do this? The plugin will be used on three pages of the wordpress site. It will use the same theme, though It will have three different page templates. Is it possible to group the templates together in a sub-folder inside the theme or plugin. The pages will be static ie dont need to be available to wp-admin.

How it currently is…..

Read More

option a -> templates in theme root, using wordpress page admin.

Below is two ideas of how i’d like it to be….

option b -> sub folder in theme with static pages (No need to create/edit in wp-admin).

option c -> self contained templates inside plugin folder using current theme, and custom filters/ actions with static pages (No need to create/edit in wp-admin).

This plugin is essentially a section of the wordpress site grouped together that uses the wordpress objects and database. It will have its own loops and pages.

/wp-content/plugins/mycustomplugin/mycustomplugin.php
/wp-content/plugins/mycustomplugin/templates/default.php
/wp-content/plugins/mycustomplugin/templates/template2.php
/wp-content/plugins/mycustomplugin/templates/mycustomplugin-loop.php

or

/wp-content/plugins/mycustomplugin/mycustomplugin.php
/wp-content/themes/mytheme/mycustomplugin/mycustomplugin.php
/wp-content/themes/mytheme/mycustomplugin/template2.php
/wp-content/themes/mytheme/mycustomplugin/mycustomplugin-loop.php

Related posts

Leave a Reply

1 comment

  1. If this is a plugin you should really keep the files in your plugin folder. Alternatively you can use the theme folder under it’s own name separate from the active theme. I have seen the latter done and it works fine but you don’t want some unsuspecting users to activate it by mistake. You should never write to the active theme or any theme the user has installed.