Skip Navigation

[Resolved] Displaying Term Fields on the Front-end

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

Problem:
The user is building a theme and would like to display some term fields inside the single post template file.

Solution:
Use similar code to this one to get the values of the terms:

$taxonomy_slug = "book-author";
$authors = get_the_terms( get_the_ID(), $taxonomy_slug );
$author_ids = wp_list_pluck( $authors, 'term_id' );
foreach ($author_ids as $author_id) {
    echo types_render_termmeta("foto-del-autor", array( "term_id" => $author_id, "width" => "100", "height" => "100" ) );
}

Update the first line with your taxonomy slug.
Relevant Documentation:

This support ticket is created 4 years, 1 month 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 3 voices.

Last updated by Paulo Ramalho 4 years ago.

Assisted by: Jamal.

Author
Posts
#2014543

Hi all.
I'm still having problems with this thread.
https://toolset.com/forums/topic/displaying-term-fields-on-the-front-end-2/

The diference is right now I have the web on pre-production. I can send admin credentials if needed.

hidden link
At the end of the post you'll see the author's card. I can print the name and description, but not the image field of author's photo.
Thanks.

#2014827

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The link to your site you shared, that is for a single post (of the CPT opinion).

You have custom user fields, including an image field, and you want to output that image for the author of this post, is that correct?

But you are editing the PHP templates directly, is that right?

#2015683

Hi Nigel.
I have custom taxonomy fields. Due to format of the project I do not want to have user fields. I have term fields. I have explained everything here https://toolset.com/forums/topic/displaying-term-fields-on-the-front-end-2/ but I can't follow with that thread. I was very busy with the project and the thread was canceled.

If you want I can send you and admin login. Any help is fully apreciated. Thanks.

#2016067

You are trying to display fields from the taxonomy(Authors) term inside the single post(Opinion) template. You will need to get the id of the terms using the get_the_terms WordPress function. Some thing like:

			$taxonomy_slug = "book-author";
			$authors = get_the_terms( get_the_ID(), $taxonomy_slug );
			$author_ids = wp_list_pluck( $authors, 'term_id' );
			foreach ($author_ids as $author_id) {
				echo types_render_termmeta("foto-del-autor", array( "term_id" => $author_id, "width" => "100", "height" => "100" ) );
			}

- https://developer.wordpress.org/reference/functions/get_the_ID/
- https://developer.wordpress.org/reference/functions/get_the_terms/

Update the first line with your taxonomy slug.

I hope this helps. Let me know if you have any questions.

#2019759

Hi Jamal.
Thank you very, very much. It works like a charm. Perfect.
I was really in trouble with this. I do not use Views anymore and I fell like Blocks is not the same tool yet.
Thank you again. Problem solved.

Paulo

#2019761

My issue is resolved now. Thank you!