Skip Navigation

[Resolved] Displaying Term Fields on the Front-end

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 11 replies, has 2 voices.

Last updated by Shane 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1992113

Hi.
I'm having troubles to display a term custom field on front end of my project.
I've created a custom IMAGE field called "foto-del-autor" on a custom taxonomy called "autores".

<?php echo types_render_termmeta("foto-del-autor", array( "alt" => "Category Featured Image", "width" => "100", "height" => "100" ) ); ?>

This (and other shortcuts) do not work for me.

Any help will be fully apreciated. Thanks.

#1992715

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paulo,

Can you provide me with admin access to the page that you are testing this on ? As well as where the code is located so that I can have a short look as to how you are setting this up.

Based on your code the field should render the information.

I've enabled the private fields for your next response.

Thanks,
Shane

#1993299
screen03.jpg
screen02.jpg
screen01.jpg

Hi Shane.
I'm working on localhost, sorry. And yes, it supposed to work I don't know what's the problem here.
I can show you some screens.

author-name and author-desc works well. But the two are text format.
<?php echo do_shortcode('[wpv-post-taxonomy type="autor" separator=", " format="text" show="name" order="asc"]'); ?>
<?php echo do_shortcode('[wpv-post-taxonomy type="autor" separator=", " format="text" show="description" order="asc"]'); ?>

#1993557

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paulo,

Based on your screenshots it would appear that you're trying to pull this data on a Post output screen and not a taxonomy Archive. You can only display the taxonomy meta under 2 scenarios:
1. If you're on a taxonomy archive
2. If you specify the exact term id of the taxonomy term that you want to display.

From your screenshot none of these conditions are being met. In this case you will need to create a view to display the term meta given that we are unable to get the ID of the taxonomy term with any of our shortcodes.

You can use the function below to get the term object and then pick off the ID and pass it into the types_render_termmeta() function in order to get the correct information.
https://developer.wordpress.org/reference/functions/get_term_by/

What you will need to do is to use the'[wpv-post-taxonomy type="autor"] shortcode to return the slug and store that in a variable. Then pass the slug into the get_term_by function and which returns the term object.

Please let me know if this provides some clarity and points you in the right direction to get this resolved.

Thanks,
Shane

#1995029
Untitled-1.jpg

Hi Shane.
My taxonomy is OPINION and its terms are AUTORS.
And yes, this is a taxonomy file: single-opinion.php
You can see it on top of the last screenshot.

All I want to do is a Card of the autor of the text in the page, as you can see in the code . I can display the term description and the name of the autor, but NOT its photo.

#1995855

Hi Shane.
I still can't solve my problem.
🙁

#1996313

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paulo,

Would you mind allowing me to have admin access to the site so that I can have a further look at this one for you ?

I've enabled the private fields for your next response.

Thanks,
Shane

#1996437

Hi Shane, thanks for your reply.
I'm developing in localhost. I can paste the single-opinion.php code here if helps you.

Thanks.

#1996703

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paulo,

No worries, you can provide me with a copy of the exact site. Its usually faster to debug with the entire site in hand rather than just the file because the file alone may not give the full context.

You can use the plugin below in order to provide me with the site copy.
https://wordpress.org/plugins/duplicator/#:~:text=Duplicator%20is%20the%20most%20powerful,or%20hosts%20with%20zero%20downtime&text=Transfer%20a%20WordPress%20site%20from,or%20parts%20of%20a%20site

I've also enabled the private fields for your next response.
Thanks,
Shane

#1998823
Untitled-1.jpg

Hi Shane, thank you for your reply.
I really see a bit confusing having to duplicate a big entire website right now, I'm very busy with development and have a very tight deadline.

I've been using Toolset for several years now and I wouldn't want to use another plugin to do something that seemed simple. But I think it will have to be my alternative. Or some another custom function.

#1998885

Hi shane.
I can make it work with this one, However I do not know how to get the ID of the current term.

<?php echo types_render_termmeta("foto-del-autor", array( "term_id" => '881', "width" => "100", "height" => "100" ) ); ?>

Please, any help is fully apreciated.
Thanks again.

#1999213

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paulo,

It is quite difficult to tell what is wrong without knowing the context of the site.

However you should be able to get the current taxonomy id with the following function.
$term_id = get_queried_object() -> term_id;

If this is a taxonomy archive then the get_queried_object() function should give you the taxonomy object that is currently being queried and allow you to pick the ID from it.

Please let me know if this was able to help you progress further.

Thanks,
Shane