# List one authors' posts

**URL:** <https://discourse.gohugo.io/t/list-one-authors-posts/29055>\
**Category:** support\
**Created:** [October 27, 2020, 1:44am UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055 "2020-10-27T01:44:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [October 27, 2020, 1:44am UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/1 "2020-10-27T01:44:26Z")

</div>

This has to be simple 🙂 I have authors set up as a taxonomy in config.toml. I’m using the function below in a `sidebar.html` to list the five most recent posts by all authors:

```
 <ul class="recent-posts">
  {{- $recent_articles_num := (.Site.Params.widgets.recent_articles_num | default 5) }}
  {{- range first $recent_articles_num (where .Site.RegularPages "Section" "in" (.Site.Params.postSections | default (slice "posts"))) }}
     <li>
      <a href="{{ .RelPermalink }}">{{ .Title | truncate 50 }}</a>
      </li>
    {{- end }}
</ul>

```

How can I list the five most recent posts by one specific author?

How do call that one author in the range? Or is there a better way?

And what happens if a post has more than one author? Will that post show up in each authors’ listing?

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [October 27, 2020, 6:55am UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/2 "2020-10-27T06:55:59Z")

</div>

Assuming you have

```auto
[taxonomies]
  author = "authors"

```

You can `.GetPage` the author page, something like:

```auto
{{ $author := site.GetPage "authors/arthur-conan-doyle" }}
{{ range first 5 $author.Pages }}
  {{ . }}
{{ end }}

```

See: [https://gohugo.io/templates/taxonomy-templates/#sitegetpage-for-taxonomies](https://gohugo.io/templates/taxonomy-templates/#sitegetpage-for-taxonomies)

---

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [October 27, 2020, 3:35pm UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/3 "2020-10-27T15:35:41Z")

</div>

Thanks! That works. I realized that I don’t need the `.Site.Params.widgets.recent_articles_num` in my first example; that was a holdover from a theme I modified.

Now I’m trying this: since an author can have posts in two different Sections, and I want to limit the output to “posts”, this is what I came up with, but it throws the error “wrong number of args for first: want 2 got 3.”

```
{{ $author := site.GetPage "authors/arthur-conan-doyle" }}
{{ range first 6 $author.Pages (where .Site.RegularPages ".Type" "posts" ) }}
<ul class="recent-posts">
<li>
<a href="{{ .RelPermalink }}">{{ .Title | truncate 50 }}</a>
</li>
</ul>
{{ end }}
```

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [October 27, 2020, 11:59pm UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/4 "2020-10-27T23:59:03Z")

</div>

You have to do something like:

```auto
{{ range first 6 (where $author.Pages ".Type" "posts" ) }}

```

---

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [October 28, 2020, 2:30am UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/5 "2020-10-28T02:30:29Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 30, 2020, 2:30am UTC](https://discourse.gohugo.io/t/list-one-authors-posts/29055/6 "2020-10-30T02:30:32Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
