I've created a custom post type named "accommodation" and taxonomy for it named "categories" using the file "taxonomy-accommodation-categories.php" - this is working fine in my WordPress theme.

But I want to add this in a separate plugin instead, does anyone know how I can do this?

Appreciate any help, thanks.


This works:

add_filter('template_include', 'taxonomy_template');
function taxonomy_template( $template ){

if( is_tax('accommodation-categories')){
    $template = BASE_DIR .'/templates/taxonomy-accommodation-categories.php';

return $template;

  • Please add a proper explanation to your code – Pieter Goosen Oct 8 '15 at 6:56

You can create Page template in your plugin and add following filter which will called template from your plugin

add_filter( 'page_template', 'wpa3396_page_template' );
function wpa3396_page_template( $page_template )
    if ( is_page( 'my-custom-texonomy-slug' ) ) {
        $page_template = dirname( __FILE__ ) . '/template-neme.php';
    return $page_template;
  • Thanks for the reply - that was close but didn't work. I found the is_tax function and this works is_tax('accommodation-categories') – The Bobster Oct 8 '15 at 6:26
  • page_template is only for the page post type, taxonomy_template is the filter for taxonomies. – Milo Oct 8 '15 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.