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:

https://gist.github.com/chmchm/17089c6a9bcd908f85d4


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:


https://gist.github.com/chmchm/11feda0e6383a0f14eb8

The result looks like this with downloadable link and an orderby count thrown in:

 

Screen Shot 2015-10-21 at 2.38.47 PM

 

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!

 

 

Posted in ,

chm