• hello,
    im making custom taxonomy and i want for each taxonomy type to be able to select template file.
    For categories im getting good result, when i select custom template file , adding to body_class hook with name exmpl : category-template-1.php and its displayed correctly
    wanna do same thing with taxonomy exmpl i want taxonomy-template-1.php file to be loaded but it keeps pointing to taxonomy.php
    i know about taxonomy-{slug}.php and similar things but thats not what i want.
    thanx in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It goes to taxonomy.php because it cannot find taxonomy-{slug}.php. Why don’t you go ahead and create a taxonomy-{slug}.php template? Then script there loads the actual template file you want based on whatever criteria you decide. Or modify taxonomy.php to do the same thing.

    Thread Starter ragesoul

    (@ragesoul)

    similar stuff works for ‘category’, if user leave default category page, it goes to ‘category.php’, if user selects category-template-1.php via body class it goes to category-template-1.php..
    no chance to somehow control which page gonna be loaded for taxonomies too.

    Moderator bcworkz

    (@bcworkz)

    I can’t explain why it works for categories and not other taxonomies. The fact is ‘body_class’ is not an appropriate hook for managing templates anyway. I’m surprised it works for categories actually. Even so, I suspect you are getting invalid HTML doing it that way. It may be interesting to run your page through the W3C validator.

    The main template loading functions do not have any filters to hook into. It seems clear you are meant to work off the default templates in order to load more specialized templates. By placing appropriate code on taxonomy.php, you can load any other taxonomy template you want.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘getting custom template pages’ is closed to new replies.