Hi Christian,
I am almost done setting up my membership site and posting support questions. Thank you for your help.
This is an add-on question to https://toolset.com/forums/topic/help-setting-up-term-pagination-in-term-archive-pages/.
I'm looking for a way to modify the Custom Code you gave me to limit the term pagination to just within the 2nd level term of the archive, for instance within the "Knitting Superstar" term or "Fearless Knitter" term.
Right now, having added other classes to my class-parts taxonomy, the term pagination want to skip to those other classes.
If I number the class parts 1, 2, 3, 4, for each class in the taxonomy, the Next Chapter navigation on the Fearless Knitter class points to the next chapter in the Knitting Superstar class.
If I number the class parts 1, 2, 3, 4 for the first class and 5, 6, 7, 8 for the second class, the last page of the class will have a navigation link to the first page of the next class.
I want to avoid having the navigation point to chapters in different classes. People should just be able to navigate within that class, i.e. anything that is within the 2nd level term.
In the attached screenshot I'm hovering over the "next chapter" link, and in the url preview in the bottom left you can see that it goes to a chapter in the Knitting Superstar class. But in the URL bar above you can see that I'm in the Fearless Knitter class.
Thank you!
Liat
It looks like you need to be able to filter the Next and Previous Views by term ancestor, based on the current archive term's ancestors. Views offers a term parent filter, but no filter for term ancestor (farther back than parent, like grandparent or great-grandparent). So there are a couple of other ways to do this - a custom field, or a dynamic term ID filter.
1. Custom Field Filter: Add a custom field to the Class Parts taxonomy. For each class, use a different field value. So for Knitting Superstar and all its descendant terms, use "knitting-superstar". For Fearless Knitter and all its descendant terms, use "fearless-knitter", etc. Then add a filter to the Next and Previous Views that filters by this custom field, set by a shortcode attribute. In the View shortcodes for the Next and Previous View, use a Types termmeta shortcode to insert the current term archive's custom field value in a shortcode attribute. This will filter the View by class part. This option is probably the fastest to set up, but arguably more difficult to maintain because you must manually manage these custom field values.
2. Dynamic Term ID Filter: Add a taxonomy term filter to the Next and Previous Views. Set it up to filter by term ID using a shortcode attribute "ids". This lets you add class part term IDs to the View shortcodes, like this:
[wpv-view name="class-parts-filtered-by-part-order-next" ids="1,3,4,23,39"]
This View will only show terms whose IDs are 1, 3, 4, 23, or 39. You would need a way to make the "ids" dynamic, based on the current term archive. That will require a custom shortcode that inspects the current archive's term ancestors and returns a list of the term childrens' ids. This will be more difficult to set up, but arguably easier to maintain because you don't have to maintain a custom field value in all the terms.
Let me know which approach you would prefer and I can offer some more detailed advice.
Hi Christian,
Thank you so much!
I am definitely ok with setting up a custom field and putting in some value for each class. I could put in "fk" for Fearless Knitter or "ks" for Knitting Superstar.
I am going to attempt this on my own. I'll be back with questions shortly.
Liat
It worked perfectly! I was able to follow your directions and use the shortcode filters and termmeta shortcode to filter the views.
Thank you SO SO much for providing instructions I can follow.
Cheers!
Liat