Skip Navigation

[Resolved] Display Term Fields on Archive Page

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display term custom fields for the current archive term, using Views.

Solution: In a taxonomy term WordPress Archive, you can use the Types field shortcode to display information about the current term, by default. However, if you want to use Views instead, you can apply a term filter by shortcode attribute, and pass the current term ID into the filter using the wpv-taxonomy-archive shortcode like this:

[wpv-view name="your-term-view-slug" terms="[wpv-taxonomy-archive info='id']"]

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-154477

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 2 voices.

Last updated by Ben 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1174775

Ben

Was there any update with the new feature request highlighted in this thread?

https://toolset.com/forums/topic/display-term-fields-on-archive-page/

I am now facing the same problem. Trying to display Custom Term Fields on an Archive page using a View.

#1174897
Screen Shot 2018-12-30 at 4.17.07 PM.png

Hi, as Juan says in the ticket you can simply use the Types field shortcodes to display custom field values from the current archive term. You should not use Views, unless there is a good reason. If you must use Views for another reason I am not aware of, there is a different approach available. In the Query Filter section of a taxonomy View editor, set up a filter by Taxonomy term where the term is set by a shortcode attribute terms. See the attached screenshot. If you cannot see the Query Filter panel, scroll up to the top right corner and click "Screen Options" to activate it.

When you insert this View in your WordPress Archive or Template Layout, you will include the terms shortcode attribute, and pass the current archive term ID into the filter with the wpv-taxonomy-archive shortcode:

[wpv-view name="your-term-view-slug" terms="[wpv-taxonomy-archive info='id']"]

Then in the Loop editor of this View, you can insert the custom term fields using the Fields and Views button. The View will display custom field values from the current archive term. But again, unless there is a good reason to use Views here, just use the Types field shortcode to display term field information for the current archive. We have documentation about that available here:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Click the orange "More info" buttons to display examples for term fields.

More information about the Views approach:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-154477

#1175340

Ben

Thanks for your reply Christian.

I like to use Views as I find they allow me to organise and update a lot of data from one place better. If I place these bits of data individually into a template I often find it harder to update them, as I can't view them all at once like I can in a View.

When I try to use your solution here, the Term Fields do not output properly and I get the following displayed after the output leading me to believe that something is wrong with the shortcode.

"]
#1175341

Ben

I'm not sure why that didn't display properly. It was mean to be:

"]

#1176077

May I log in and see how you have this set up? Let me know which term archive I should be checking.

#1176899

Check it now, I've replaced the shortcode element with a standard text element and the extra quotation mark and bracket are no longer appearing. Is there anything else going wrong in the output?

#1177755

Ben

Perfect! That displays exactly as required using the text element.

Thank you very much for all your help with these issues Christian.