Ok, here’s how I achieved it… but it’s not elegant at all 🙁
<ul id="stocksymbols">
[pods name="taxonomy_name_cities"]
[if include_in_tax_query_custom_field]
<li>{@name}</li>
[/if]
[/pods]
[pods name="post_type_name_location"]
[if single_in_city_custom_field]
<li>{@name}</li>
[/if]
[/pods]
</ul>
Then I used JS I found online to reorder the items Alphabetically, since they are all in the same UL.
<script>
function sortList(ul) {
var ul = document.getElementById(ul);
Array.from(ul.getElementsByTagName("LI"))
.sort((a, b) => a.textContent.localeCompare(b.textContent))
.forEach(li => ul.appendChild(li));
}
sortList("stocksymbols");
</script>
So basically…
1. I am querying the taxonomy terms and posts separately then merging them and reordering them via JS.
2. To exclude one taxonomy I am using a Y/N custom field on taxonomies. This is also not elegant since I have to set all the terms I want to include to Y and the term I want to exclude to N.
3. To include only the posts inside the excluded taxonomy I am using another Y/N custom field.
I certainly hope there is a better solution to this…
So what I’m looking to achieve is Exclusion Rules (for the taxonomies) and Inclusion Rules based on taxonomy for posts…
I can live with sorting the <.li.> elements via JS.
Thank you and I hope you have some ideas.
-
This reply was modified 4 years, 10 months ago by
coadr93.
-
This reply was modified 4 years, 10 months ago by
coadr93.
Hi @coadr93
Personally I would advice you to go the PHP route for this one. You can combine the results of your queries and reorder properly before running your loop.
Pods templates aren’t meant for sunning complex queries, PHP is way more flexible.
Cheers, Jory
Hey, Jory! Thanks for your reply.
Can you link me to any documentation that might be helpful for PHP pods template?
I’ve been browsing the pods.io website but mostly 404s or pages that have no content…
Sorry about the 404s, I’m working as quickly as possible to resolve the issue this week and get everything back up.
Hey, Scott. Thanks! 🙂 You guys are doing a great job! I hope I will be able to help at some point with the documentation but I’m still learning Pods myself.
Just following up, this past weekend we spent days working on this and most of those 404s should be resolved.
We are not going to bring over the pods_api() docs because we will instead spend that time working on the new Code Reference site that is phpdoc powered. There’s too many methods to bring over and the process was very time intensive.
Thanks for the update and for your work, Scott!