[Resolved] Help setting up “term pagination” in term archive pages.
This thread is resolved. Here is a description of the problem and solution.
Problem: I am using term archives to display posts without pagination, and I would like to create Next and Previous links to paginate to another term archive page. The sort order should be determined by a custom field on the terms.
Solution:
Use Views filtered by term where the term ID is set by a shortcode attribute. Pass the current term's field value into the filter and sort by the term field value. Use the following custom shortcode to determine the current term's order.
To prepare, I set up a custom number field "part order" for my custom "class part" taxonomy and set numbers 1-9 for the taxonomy terms. I set the numbers in order independent of the hierarchy levels as follows: (see Screenshot: Part Orders). I figured we could set the view to navigate to the next parent term if that's where the user is, or the next child term if that's where the user is. Let me know if you want me to set the part order numbers differently.
I then created two views of the taxonomy terms filtered by part order. See screenshots: Class Parts Filtered by Part Order - Next, and Class Parts Filtered by Part Order - Previous. I used the fake shortcode attribute "tbd" as a holding spot until you give me the right shortcode attribute(s).
I then added these view to the layout. See screenshot: Previous/Next Navigation on Layout - First Attempt. I tried to put them side by side by using 6 columns for each cell, but they ended up stacking. Obviously all the links show up right now as the filter is a fake one, but see screenshots: Current "Previous" Links and Current "Next" Links. Once we get the coding right, can you help me format the layout so that one term shows up on the left and the other shows up on the right? (as in Screenshot: Desired Layout for Next/Previous Term Links).
I think that is all I can do on my end for now, can you help me set up the shortcodes and anything else you see that I may not have done right?
Okay these are the next steps:
- Edit the "Previous" View and change the Order to be ordered by part number, descending, instead of term name. Then change the number displayed to be 1 instead of "No limit".
- Edit the Query Filter to be set by a shortcode attribute "partnum" instead of a URL parameter.
- Edit the "Next" View and change the Order to be ordered by part number, ascending, instead of term name. Then change the number displayed to be 1 instead of "No limit".
- Edit the Query Filter to be set by a shortcode attribute "partnum" instead of a URL parameter.
- Edit this Layout and remove the two View cells you are currently using to place the next and previous buttons. Replace those two cells with one Visual Editor cell, spanning the full width of the Layout.
- Insert the Previous View and the Next View in the Visual Editor cell using the Fields and Views button. In the popup dialog, use the left tabs to add the shortcode attribute "partnum", and for now set it to be 3.
- Test the new Layout and Views on the taxonomy archive that corresponds to part number 3. You should see the next and previous links appear, and they should be displaying links to part number 2 and part number 4.
Let me know if you get through these steps or run into trouble and I'll take a look. Next we will make the links dynamic, based on the current taxonomy archive. Then we will work on a few final touches and formatting.
In order for those to work, you must register "archive-part-num" in Toolset > Settings > Front-end content > Third party shortcode arguments. However, I'm getting 504 Gateway timeout errors on that page again. Do you have access to server logs? Can you see if any information is logged that can help explain these timeouts?
I just got off the chat with my web host, and they found nothing in the server logs to explain the timeouts for that page. They did try to troubleshoot but could not get into the page despite their best efforts. They suggested I contact the plugin developers or a dedicated WordPress developer.