WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add the custom page template selector that can be found in the "edit page" screen for pages to a custom taxonomy. The custom taxonomy is product_cat created by WooCommerce.

I am using the Tax-meta-class created by Ohad Raz of en.bainternet.info. This allows me to add a meta box to the the "edit product categories" screens. Ohad Raz has also authored a plugin that adds a custom page template selector menu to the "edit category" screens. However it does not show for the custom taxonomy.

I can get the selector menu to out put the templates by adding:

<?php page_template_dropdown($template); ?>

to the Tax-meta-class.php. It out puts the proper values that i can use later in a template redirect but it won't save.

The built in way to add a drop down selector has you choose the options values and names by adding them to an array like so:

array('selectkey1'=>'Select Value1','selectkey2'=>'Select Value2')

Which outputs this:

<option value='selectkey1'>Select Value1</option>
<option value='selectkey2'>Select Value2</option>

if I use the code:

$templates = get_page_templates();
foreach ( $templates as $template_name => $template_filename ) {
   echo $template_name . ' ' . $template_filename . ' ';

I can get it to output:

Contact Page contact-page.php EVENT Pageevent-page.php Product
Icon product-icon.php Product SubFeature product-subfeature.php
Lockable Dowel template-lockable-dowel.php

I was hoping there would be a way to store these values in an array that can be used in place of:

array('selectkey1'=>'Select Value1','selectkey2'=>'Select Value2')

This way it will be using the Tax-meta-class how it should be and everything should work fine.

I am fairly new and all self taught so please excuse me if I have not asked in the proper way. Thank you for taking the time to rean my question.

Sincerely, Leon

share|improve this question

get_page_templates already returns an array:

    [Sidebar] => sidebar.php
    [Category] => category.php
    [Page] => page.php

If you need to swap keys and values you can use php's array_flip.

share|improve this answer

I don't know what you need to do that.

If you are creating a custom taxonomy you can just copy your archive.php content copy the whole php in it.

Create a new file in your template called "taxonomy-yourcustomtaxonomyname.php" paste the code from archive.php you just copied, and WP will handle the rest :)

you can learn more about custom templates for custom taxonomies here:



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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