0

How can I show only read more link, and remove or unset other links like "add new comments" or "2 Comments" at the end of a node teaser?

Mojtaba Reyhani
  • 447
  • 1
  • 6
  • 19

1 Answers1

1

In order to have custom links, you need the links--node.html.twig template file, it does theme override to display node links.

1. Paste this:

This is links.html.twig talking.... 
{% if links -%}
  {%- if heading -%}
    {%- if heading.level -%}
      <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}</{{ heading.level }}>
    {%- else -%}
      <h2{{ heading.attributes }}>{{ heading.text }}</h2>
    {%- endif -%}
  {%- endif -%}
  <ul{{ attributes }}>
    {%- for key, item in links -%}
      <li{{ item.attributes.addClass(key|clean_class) }}>
        {%- if item.link -%}
          {{ item.link }}
        {%- elseif item.text_attributes -%}
          <span{{ item.text_attributes }}>{{ item.text }}</span>
        {%- else -%}
          {{ item.text }}
        {%- endif -%}
      </li>
    {%- endfor -%}
  </ul>
{%- endif %}

into your editor

2. Customise at will.

3. save as themes/YOUR_THEME/templates/links.html.twig

4. clear cache

5. See it in action

Thanks for your feedback.

Augusto
  • 2,125
  • 18
  • 27
  • I have such as this file in my templates directory in my theme folder as Default, but I do not know how to customize it, Can you help me to reach my goals with give more information about this problem. – Mojtaba Reyhani Feb 29 '16 at 09:16
  • Since it would be your next step, I suggest you to post a new question providing what you expect the links--node.html.twig should produce. In the meantime, thanks for feedback on my reply. – Augusto Feb 29 '16 at 09:32