Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Link to posts by author

Solved by Pedro M View solution

Started by Pedro M 5 years ago · 4 replies · 536 views
5 years ago

Hello there

I have in blog_item.html.twig the following code to show the author of post:

TWIG
{% if page.header.author %}
  <a href="{{ page.url }}" class="author"><span class="name" rel="author">{{ page.header.author }}</span><img src="{{ page.media[page.header.avatarImage].url|e}}" alt="{{ page.header.author }}" /></a>
{% endif %}

I'd like to configure in href="" the code to call all articles posted by the author (similiar to list of posts by taxonomy). author is defined in configuration as taxonomy type.

How I can do this?

Thanks in advance.

5 years ago

@pmoreno, What have you tried so far?

5 years ago

Hi

I have the following:

TWIG
{% set author =  page.header.author %}
{% if author %}
  <a href="{{ base_url }}/tag{{ config.system.param_sep }}{{ author }}" itemprop="keywords" class="author">{{ tag }}<span class="name" rel="author">{{ author }}</span><img src="{{ page.media[page.header.avatarImage].url|e}}" alt="{{ author }}" /></a>
{% endif %}

Thanks

5 years ago Solution

Hi again.

I've just find the solution

The correct code is:

TWIG
<a href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="keywords" class="author">{{ tag }}<span class="name" rel="author">{{ author }}</span><img src="{{ page.media[page.header.avatarImage].url|e}}" alt="{{ author }}" /></a>

I'd only to have change /tag to /author

👍 1
5 years ago

@pmoreno, Asking someone else may be easier, but not as fulfilling as finding a solution yourself... ;-)

As a bonus, you may mark your reply as 'solution'.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 133 24 hours ago
General · by pamtbaau, 1 day ago
1 92 1 day ago
General · by Andy Miller, 2 days ago
0 77 2 days ago
General · by Marcel, 12 months ago
6 386 5 days ago
General · by Duc , 6 days ago
3 71 6 days ago