• Hi, I am building my second template from scratch so bear with me and my lack of knowledge. Day 2 now googling to solve my issue so Im hoping to get some direction here so thank in advance!. I have a taxonomy-{cpt}.php file which is working fine sorting and displaying my CPT custom categories when user chooses category from menu. On each category page I need to additionally sort posts into sections based an additional custom taxonomy and also custom tags. I thought I could do this using multiple loops but when I try to modify the query and create a loop for each section the posts are no longer separated by category, rather, each category page shows all of the posts. So I tried a different approach following this great tutorial on sorting by a second taxonomy which seemed to be what I needed but I fell short at the end not understanding how to include a third taxonomy within the foreach loop to sort one step further. (https://code.tutsplus.com/tutorials/taxonomy-archives-list-posts-by-a-second-taxonomys-terms–cms-20450) So I went back to my original approach after reading this could possibly be done using pre_get_posts. Again, futzing with that didn’t get me anywhere. Can someone please steer me in the right direction as to how to accomplish sorting posts by terms on my taxonomy-{cpt}.php file so I can focus on one direction and get over this hump? The final result needs to be this:

    Section for audience A (custom-category: Doctors)

    Resource Links (custom-tag: resource)
    —(list all book titles for audience A)
    Videos (custom-tag: video)
    —(list all video titles for audience A)

    Section for audience B (custom-category: Patients)

    Resource Links (custom-tag: resource)
    —(list all book titles for audience B)
    Videos (custom-tag: video)
    —(list all video titles for audience B)

    Is there maybe a different approach I have not thought of? Anyone with any support would really help me out. This is actually a real project for my job (as graphic designer not web developer) so thanks.

    Here is a sample temporary link where I need this to appear. Right now its a mess trying so many different ways to do this.

    https://www.corpakms.net/category-corpaku/farrell-u/

  • The topic ‘problems sorting posts by taxonomy in template file’ is closed to new replies.