[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 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.

Related documentation: Content Templates

This topic contains 3 replies, has 2 voices, and was last updated by  jornB 11 months, 1 week ago. The support staff assigned to this topic is Shane.

Viewing 4 posts - 1 through 4 (of 4 total)
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
Forum moderator

Supporter languages: English (English )

Supporter 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
Forum moderator

Supporter languages: English (English )

Supporter 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 ?

Viewing 4 posts - 1 through 4 (of 4 total)

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