Want to display entries of a Custom Post Type on its archive page grouped by the custom taxonomy terms?
We are going to check if there's at least one term assigned to any of the published entries and if so, remove the default loop and add a custom loop with the code for displaying CPT entries organized by their custom taxonomies. If none of the published entries has been assigned to any taxonomy term, then the standard Genesis loop will be shown.
In this example, I have used Pods for registering "KB Items" (
kbitem) CPT and a corresponding "KB Categories" (
kbcategory) custom taxonomy.
Tip: Make sure you check "Enable Archive Page" in the advanced options when creating/editing your CPT in Pods.
Create a file named
cpt is the name of your CPT having the code below. In this example, the file is named archive-kbitem.php.
To view the full content, please sign up for the membership.
Already a member? Log in below or here.