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

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Related documentation: Content Templates

This topic contains 3 replies, has 2 voices, and was last updated by  jornB 6 days, 11 hours 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)

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Known issues and their solutions

We document known issues and their solutions in Toolset erratas. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.

Support Policy

Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

For more information, read our full Customer Support Policy.

Need custom programming work for your site? Check out our certified partners.