I have to necessarily use a badly structured database, and each record in a custom post type (let’s call it FILES) has 3 categories with no relationship between them(c1, c2, c3)
C1 and C2 are hardcoded, and so I define them ‘by hand’ in the first query in bricks UI, but C3… I have to make a list of all C3 terms.
So I create the query not by Taxonomy but by Post type FILES, passing C1 and C2 as filters.
Using the tag {post_terms_C3} I get all the terms out, but they are duplicates (if several FILES records share the taxonomy, it repeats).
How can I make the terms listed unique? ty
Not clear on what you want to achieve. You say 3 categories C1-C3. Then say ‘all C3 terms’ - does this mean C£ is a taxonomy, and you have 3 taxonomies for one post type? Or do you mean Child Terms of C3?
Assuming it’s child-terms… If you want a section/column with all posts of C3, and a section with all child-terms from Taxonomy ‘Files-Tax’… then do 2 queries. One for Post-Type=FILES, INCLUDE = C3
Another a Terms query, for whatever the taxonomy name is, Parent = C3 (the ID of the term).
Thanks for your answer.
Extactly 3 taxonomy for 1 post tipe. The problem is that Cx taxs are not hierarchical.
A single db record is something like
TITLE - DESCRIPTION - IMAGE - FILEPDF - C1 - C2 - C3.
assuming that macrocategory C1 is set directly with Bricks’ filters, the flow should be: click on taxonomy C2 (blue boxes on previous image) to get list of C3 tax (unique), then click on C3 tax to get list of individual posts (FILE to download) associated with category C3.
And all this on the same page (with refresh), adding only the C parameters in the url, clicking on the categories.
I hope I have explained myself better, and thanks again for your help.
I can think of a number of approaches, but I don’t know which is best - it will depend on your DB/Code structure.
Once would be to use PODS, which allows for custom tables and integrates with Bricks. Map Pods fields to the custom DB fields to spoof them (pods doesn’t ever make or edit these fields, but now maps to them) and then you can leverage PODS for more complex searches/queries (or metabox if you have it).
WPDatatables is another option, which opens MySql queries to easier wysiwyg creation.
Another would be to run mysql queries in a helper function and just use bricks to display them (echo:my_function}
A function like this : wpdb - Get unique results from this function - WordPress Development Stack Exchange
But build the result into a string and RETURN that string.
It looks like a query on C1 works. So you could maybe pass the result of C1 to a second query… but all these options will need some code. I don’t know that you can achieve what you want with native bricks.
If it were possible, I would use something like wp-allimport to backup the data - rebuild the CPT / Tax and import it to a regular CPT / Taxonomy. Then it would be easy!
Sorry I can’t be more help.
Thank you very much, I have taken your advice and am reworking the database to create a hierarchy among the taxonomies. No point in messing around with inelegant and not practical solutions.
Thanks again for your time and valuable suggestions.