1

I've created a custom taxonomy for a custom post type. Code:

add_action( 'init', 'register_taxonomy_mytaxonomies' );

function register_taxonomy_mytaxonomies() {

    $labels = array( 
        'name' => _x( 'MyTaxonomies', 'mytaxonomies' ),
        'singular_name' => _x( 'MyTaxonomy', 'mytaxonomies' ),
        'search_items' => _x( 'Search MyTaxonomies', 'mytaxonomies' ),
        'popular_items' => _x( 'Popular MyTaxonomies', 'mytaxonomies' ),
        'all_items' => _x( 'All MyTaxonomies', 'mytaxonomies' ),
        'parent_item' => _x( 'Parent MyTaxonomy', 'mytaxonomies' ),
        'parent_item_colon' => _x( 'Parent MyTaxonomy:', 'mytaxonomies' ),
        'edit_item' => _x( 'Edit MyTaxonomy', 'mytaxonomies' ),
        'update_item' => _x( 'Update MyTaxonomy', 'mytaxonomies' ),
        'add_new_item' => _x( 'Add New MyTaxonomy', 'mytaxonomies' ),
        'new_item_name' => _x( 'New MyTaxonomy', 'mytaxonomies' ),
        'separate_items_with_commas' => _x( 'Separate mytaxonomies with commas', 'mytaxonomies' ),
        'add_or_remove_items' => _x( 'Add or remove mytaxonomies', 'mytaxonomies' ),
        'choose_from_most_used' => _x( 'Choose from the most used mytaxonomies', 'mytaxonomies' ),
        'menu_name' => _x( 'MyTaxonomies', 'mytaxonomies' ),
    );

    $args = array( 
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'show_admin_column' => true,
        'hierarchical' => true,

        'rewrite' => true,
        'query_var' => true
    );

    register_taxonomy( 'mytaxonomies', array('MyCustomPostType'), $args );
}

Now I see a metabox on the right side of the custom post type in admin panel. Then I've added 2 new MyTaxonomies : MyTax1 and MyTax2

Now I want to show

  • my custom post type page in Template1 in front end if the the admin selects MyTax1
  • my custom post type page in Template2 in front end if the the admin selects MyTax2

Like single.php

I am not looking for archive template. I am trying to show something like Page template (like default feature in wordpress Page) - page atributes: where we see a dropdown menu that shows page templates we can select.

Or something like I would be able to select a template per/or for custom taxonomy in custom taxonomy edit page.

1

Add new file called taxonomy- mytaxonomies.php and put you code . But so far I know to add like in page..it is not available in wp yet

  • thanks for that. I tried that before I asked the question. Anyhow if I create taxonomy-mytaxonomies.php it will work as mytaxonomies 's archive. Won't it?? I mean we can list all the custom posts those categorized / classified as mytaxonomies in that page. Am I right?? – Foolish Coder Mar 30 '15 at 9:08
  • yes, exactly what you say, upvote is appreciated – Sagar Devkota Mar 30 '15 at 9:46
  • ok.. thanks.. I am unable upvote you because of my reputation is just 6. minumum 15 reputation is needed for upvote. I'll ask my friend to upvote u shortly.. – Foolish Coder Mar 30 '15 at 9:54
  • ok, you can mark as accepted answer – Sagar Devkota Mar 30 '15 at 9:55
  • upvoted. But I can't accept the answer because this is not the exact solution for the question. thanks for your time. much appereciated.. – Foolish Coder Mar 30 '15 at 10:03

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.