I created the custom taxonomy where each level = geographical area (Continents/Countries/States/Cities).
I made an archive template for custom post where I'm trying to call taxonomy view with filtering by parent.
But the features which I see only allows to filter view results by current archive taxonomy term AS a PARENT (option "Select taxonomy terms whose parent is the current taxonomy archive.)". When I need to filter view results by current archive taxonomy term PARENT AS a PARENT.
Means, if I show country archive - I want to show other countries in the block, not states. How to perform it?
I made an archive template for custom post where I'm trying to call taxonomy view with filtering by parent.
In a taxonomy term archive, you can get the parent term ID with this custom shortcode:
So in a taxonomy archive for the "category" taxonomy, you would use the shortcode like this:
[get_term_parent_id taxonomy='category']
You must register this shortcode to be used as a third-party shortcode attribute. Go to Toolset > Settings > Front-end Content and add get_term_parent_id in third party shortcode arguments.
Then, you can create a View of the taxonomy filtered by parent term ID, set by a shortcode attribute "terms". Use the custom shortcode to set the parent term ID, like this:
[wpv-view name="Your sibling term View" terms="[get_term_parent_id taxonomy='category']"]
Then in the loop of that View, output whatever information you want to display for all the sibling terms.
I'm a bit modified your code because I have up to 4 level terms when you was written for the case of 2 lvls, huuuh, dived to the PHP + WP coding, long time didn't do it… Now the function returns real parent term id.
But now I have problems with passing parent term id. Yes, I found that if you filter by "taxonomy term" - it's clearly visible you can pass terms ids in the "terms" or any custom field.
But for "taxonomy parent" case I have no idea how to pass it. It's only said "Parent is the taxonomy selected by the parent Taxonomy View" and nothing more! Pls, clarify what it meaning and how to set the parent term id, or maybe it's need to update plugins to make same set of parameters for parent filter?
P. S. I added 2 filters for make the screenshot to visualise the difference to you. Of course in experiments I'm using the only "taxonomy parent" filter.
P. P. S. I'm pretty sure that passing parent term id by terms="" parameter not works because I tried to set even numbers (real ids of terms) in [wpv-view name="Your sibling term View" terms=""], with any values view returns ALL taxonomy terms of all levels.
Ohh, everything works fine except cases, when for the main archive loop nothing found. In this case for the bottom view, which displaying neighbour places, nothing outputs either (but have to):
Function works properly - I see the correct id (parent term id). But view call - it's looks like it not works at all. Maybe some exception in the loop stops calling of any views? I had this issue even before I asked of your help and tried to call some other views, but didn't notice it.
Now I have also view which calls top level terms (w/o any parameters), I call it:
Christian is sick today. As he is already dealing with and familiar with this issue I'll let him resume with it when he returns tomorrow. (If he is unable to I will take it on.)
Hi, can you copy + paste the code from the "places-location-in-neighbourhood-by-term-id" View's Loop Editor here for me to review? Can you take screenshots showing the entire View editor screen in wp-admin?
Maybe I better give you access to the website? Because we talk about nested views and also I call other view I mentioned before from that block (depends on level of taxonomy term in current archive), so I suppose it would be faster.
It looks like the Content Templates used in the View here had become corrupted: hidden link hidden link
I rebuilt those loops without using Content Templates, and now I can see the neighbour places appear. Please take a look and let me know if it is not resolved.