Skip Navigation

[Resolved] How to insert taxonomy term field into post view

This support ticket is created 6 years, 3 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.

This topic contains 3 replies, has 1 voice.

Last updated by estlandL-2 6 years, 3 months ago.

Author
Posts
#1143961

Tell us what you are trying to do?
I have a CPT Staff with a taxonomy called Location. Each tax term (location term) has a location-url field. The purpose of the location-url field is for the client to point the location link to any url. On the staff page I have a view that queries and displays staff members including which location they work at. I want the link of the location they work at to use the location-url field.

I understand that I can't use the shortcode [types termmeta="location-url"][/types] in my staff CPT view, so I created a taxonomy view, inserted that view into a content template, and then called the content template in the staff CPT view with the shortcode [wpv-post-body view_template="location-url"]

Is there any documentation that you are following?
From https://toolset.com/forums/topic/displaying-custom-term-fields-on-post-using-avada/
"To display the Term Fields on the single post, you need to create a Taxonomy View and query the Taxonomy you used for this post type and the field's.
Then, in the Taxonomy View Query Filter you will choose "Set by the current post" and in the Loop you will output the Taxonomy Term Fields.
Then, you will insert this View in a content template, that you can then apply to the single Posts of your usage.
This will then show a list of terms fields added to this single post."

And https://toolset.com/documentation/user-guides/displaying-wordpress-term-fields/

Is there a similar example that we can see?

What is the link to your site?
hidden link

#1143992

To use a Taxonomy Term Field within a Post or Custom Post Type you must create either a separate View or a separate Content Template containing a View and nest it within your Post View.

On CPT staff view

<a href='[wpv-view name="location-view"]'> [wpv-post-taxonomy type="location" format="name"]</a>

On location view (location-url is the slug of my term field)

<wpv-loop>
   [types termmeta='location-url' output='raw'][/types]
</wpv-loop>

I also learned that you can't use a Content Template to reuse filter/search code multiple times within the same page (like with tabbed sections). And don't remove the closing div if you have multiple sorts/searches on the same page, it'll break it.

#1143993

I had a couple of staff members that worked at multiple locations so made some adjustments, creating the link within with the nested view so that I could wrap multiple links properly.

On CPT staff view:
[wpv-view name="location-view"]

On location view:

<wpv-loop>
   <a href="[types termmeta='location-url' output='raw'][/types]">[wpv-taxonomy-title]</a>&nbsp;
</wpv-loop>
#1143994

My issue is resolved now. Thank you!