Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #991769
    Baroninn
    Participant

    Hi there guys.

    Was wondering if you could take few moments to brainstorm my problem with archive-{post-type}.php
    I cant get archive{post-type}.php to work in a term or child term.

    From my understanding , I should copy wp-index.php from my current stack and rename it to archive-posttype.php
    that works… ok..
    when I visit http://my-site.com/posttype/ I get my custom archive page.. great ..

    But when I visit a term within a taxonomy from that post type I get the default index.php.

    My permalink structure is /%category%/%postname%/
    So when I click the term I get http://my-site.com/taxonomy/term

    I guess that’s because of my permalink structure.
    And I also guess thats the reason I dont get my custom archive-{post-type}.php

    Im banging my head against the wall here.
    I cant get archive{post-type}.php to work in a term
    Any ideas would be very helpful.
    I hope you dont say thats beyond the scope of…. 🙂

    Best regards
    Baroninn

    #991791
    Baroninn
    Participant

    Wow… I cannot beleve I figured it out 3 minutes after I posted this.
    I have been slamming my head against the wall for weeks about this…

    The solution :
    First off.. If anyone is having this issue, study the template hierarchy .. i didnt .. 🙂

    If you need the archive-posttype.php to work in your child term or taxonomy within the post type.
    copy that archive-posttype.php file and rename the copy to be as :
    taxonomy-{taxonomy}.php
    or
    taxonomy-{taxonomy}-{term}.php

    So, let’s say you have a CPT named “Projects,” a taxonomy named “Maintenance,” and a term within the taxonomy named “Professional.” Then your naming convention would be:

    taxonomy-maintenance-professional.php
    this should also work :
    taxonomy-maintenance.php

    I hope this helps someone….

    Best regards
    Baroninn

    #991920
    Christopher
    Moderator

    Thank you for sharing the solution 🙂

  • <script> jQuery(function($){ $("#no-reply-991769 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>