Skip Navigation

[Resolved] Print custom image filed by tag_id // PHP

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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 3 replies, has 2 voices.

Last updated by jornB 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#558629

I am trying to:
List all taxonomies (structures) with title and image dynamically on function.php

Link to a page where the issue can be seen:
goldhofer.se

I expected to see:
The tag (structure) title, link and image.

Instead, I got:
only got title and link.

The code:

		$content = "<ul>";
		foreach ($tags as $tag) {
		    $content .= "<li><a href=\"$tag->tag_link\">$tag->tag_name<span>"
				. types_render_termmeta("structure-icon", array( "term_id" => $tag->tag_id)) // Here I'm trying to print taxonomy image.
				. "</span></a></li>";
		}
		$content .= "</ul>";

    return $content;
#558661

Shane
Supporter

Languages: English (English )

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

Hi Jorn,

Thank you for contacting our support forum.

Would you mind providing me with admin access to the website so that I can have a look at this for you.

The private fields will be enabled for your next response.

Thanks,
Shane

#559740

Shane
Supporter

Languages: English (English )

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

Hi Jorn,

I took a look at this and the issue is that the taxonomy that you are checking for isn't being returned on the page automatically so you wouldn't be able to use our Types function.

If this were a post page that had this taxonomy attached in it wouldve worked.

What I did was to use the default wordpress function to retrieve the field.

'<img src="'.get_term_meta($tag->tag_id,"wpcf-structure-icon")[0].'">'

Please let me know if this helps.
Thanks,
Shane

#560660

Thanks for support it works now, but that code occurs a:

Notice: Undefined offset: 0.

Any idea how to get rid of it ?

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.