0

I've stumbled upon a situation where I want to display a link and a custom icon for the link (I'm using paragraphs module) which will be themed correctly later, BUT. After providing a taxonomy term with a image field and making it display ONLY the image by default I'm still getting a h2 of the linked terms name.

I already tried hook_entity_view, but it doesn't have separate values for icon and the randomly displayed term name - only the term id meaning I cannot unset it at this hook.

Any suggestions/experience on how should we work with this?

2 Answers 2

1

In the content type or paragraph type go to Manage Display and configure the format of the term field as "Rendered entity".

Copy taxonomy-term.html.twig to the template folder of your theme and remove the linked title: <h2><a href="{{ url }}">{{ name }}</a></h2>

taxonomy-term.html.twig

<div{{ attributes }}>
  {{ title_prefix }}
  {% if not page %}
    <h2><a href="{{ url }}">{{ name }}</a></h2>
  {% endif %}
  {{ title_suffix }}
  {{ content }}
</div>
0

Have you checked the corresponding template? To be sure just set debug: true in your root project services.yml file. the inspect the HTML code with your web browser dev tool.

You should find comments like (just an example here):

<!-- FILE NAME SUGGESTIONS:
   * field--node--title--reception-center.html.twig
   x field--node--title.html.twig
   * field--node--reception-center.html.twig
   * field--title.html.twig
   * field--string.html.twig
   * field.html.twig
-->

Then find the corresponding template and edit it in order to hide the label. In your case that template could be a field template or a term view mode template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.