List pods objects by taxonomy
I have been using Pods for a while now and try to take advantage of the templates included with Pods as much as possible. Once in a while, though, I need to code to get my desired result.
Recently, I needed to order and list my pods items by taxonomy. I had a pod, Documents, and taxonomies for those documents, File Types. I wanted to loop through each of the file types – datasheets, manuals, etc. – and list each of the documents by title.
This is the code I learned from Scott, coder extraordinaire at Pods.io:
BUT THAT’S NOT ALL! I actually had to do this on a WooCommerce product page. My products were also extended using pods… So now we have to get the params and resulting docs that are related to the product… those are the only lines that change so the final looks like this:
The result looks like this with downloadable link and an orderby count thrown in:
I understood the need for the loop, but not the syntax in PHP to pull it off. Thanks to Scott, now I do. Hopefully, this can help you, too!