# List of authors is empty

**URL:** <https://forum.getkirby.com/t/list-of-authors-is-empty/23296>\
**Category:** Questions\
**Tags:** v3\
**Created:** [September 1, 2021, 8:14am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296 "2021-09-01T08:14:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peleke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/peleke/32/4935_2.png) [@Peleke](https://forum.getkirby.com/u/Peleke)\
**Post date:** [September 1, 2021, 8:14am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/1 "2021-09-01T08:14:35Z")

</div>

I followed the [cookbook recipe for adding an authors page](https://getkirby.com/docs/cookbook/templating/authors) but it is always empty and I don’t know why. It seems to be related with the first variable but the author field exists and is set.

authors.php template:

```auto
<?php snippet('header') ?>
<?php
  // fetch all used authors emails from all articles
  $authorlist = $site->pages()->pluck('author', '-', true);
  foreach($authorlist as $author):
    echo $author; // no visible output
  endforeach;
  // get a list of all authors filtered by the ones with articles
  $authors = $kirby->users()->filterBy('id', 'in', $authorlist);
?>

<h1>Authors</h1>

<?php foreach($authors as $author): ?>
  <article class="author">
    <h1><?= $author->name() ?></h1>
    <?php if($avatar = $author->avatar()): ?>
      <figure>
        <img src="<?= $avatar->url() ?>">
      </figure>
    <?php endif ?>
    <?php if ($blog = page('blog')): ?>
      <ul class="articles">
      <?php
        // filter all articles per author
          $articles = $blog->children()->listed()->filter(function($child) use($author){
          return in_array($author->email(), $child->author()->yaml());
        });
        foreach($articles as $article): ?>
          <li><a href="<?= $article->url() ?>"><?= $article->title() ?></a></li>
        <?php endforeach ?>
      </ul>
    <?php endif ?>

  </article>
<?php endforeach ?>

<?php snippet('footer') ?>

```

Example content of one blog article:

```auto
Title: Example title

----

Author:

- kOBKf1Qa

----

Intro: 

----
...

```

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [September 1, 2021, 8:17am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/2 "2021-09-01T08:17:07Z")

</div>

> [@Peleke](#):
>
> ` $emails = $site->pages()->pluck('author', '-', true);`

`pages()` only gives you first level pages which probably don’t have an author?

---

<div class="post-metadata">

**Author:** ![Peleke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/peleke/32/4935_2.png) [@Peleke](https://forum.getkirby.com/u/Peleke)\
**Post date:** [September 1, 2021, 8:29am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/3 "2021-09-01T08:29:33Z")

</div>

Yes, you are right, if I add -\>children() then I get a list but then the second variable ($authors) will stay empty.

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [September 1, 2021, 8:34am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/4 "2021-09-01T08:34:25Z")

</div>

> [@Peleke](#):
>
> ` $authorlist = $site->pages()->pluck('author', '-', true);`

What do you get if you `dump($authorlist)`;

---

<div class="post-metadata">

**Author:** ![Peleke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/peleke/32/4935_2.png) [@Peleke](https://forum.getkirby.com/u/Peleke)\
**Post date:** [September 1, 2021, 8:37am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/5 "2021-09-01T08:37:26Z")

</div>

> [@pixelijn](#):
>
> `dump($authorlist)` ;

Array  
(  
[0] =\> kOBKf1Qa  
)

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [September 1, 2021, 9:04am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/6 "2021-09-01T09:04:01Z")

</div>

> [@Peleke](#):
>
> ```auto
> <?php
> // fetch all used authors emails from all articles
> $authorlist = $site->pages()->pluck('author', '-', true);
> foreach($authorlist as $author):
> echo $author; // no visible output
> endforeach;
> // get a list of all authors filtered by the ones with articles
> $authors = $kirby->users()->filterBy('id', 'in', $authorlist);
> ?>
> 
> ```

Hm, that should actually work then when you do a `dump($authors)`.

---

<div class="post-metadata">

**Author:** ![Peleke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/peleke/32/4935_2.png) [@Peleke](https://forum.getkirby.com/u/Peleke)\
**Post date:** [September 1, 2021, 9:12am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/7 "2021-09-01T09:12:18Z")

</div>

No, it is empty:

```auto
<?php
  // fetch all used authors emails from all articles
  $authorlist = $site->pages()->children()->pluck('author', '-', true);
  foreach($authorlist as $author):
    echo $author; // kOBKf1QA
    dump($authorlist); // Array ( [0] => kOBKf1QA )
  endforeach;
  // get a list of all authors filtered by the ones with articles
  $authors = $kirby->users()->filterBy('email', 'in', $authorlist);
  foreach($authors as $author):
    dump($authors); // no visible output
  endforeach;
?>

```

The user index.php looks like this:

```auto
<?php
return [
    'email' => 'my@email.com',
    'language' => 'de',
    'name' => 'Frederik',
    'role' => 'admin'
];

```

And the user.txt

```auto
Street: my street

----

Zip: my zip code

----

City: my city
...

```

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [September 1, 2021, 9:18am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/8 "2021-09-01T09:18:54Z")

</div>

> [@Peleke](#):
>
> ` $authors = $kirby->users()->filterBy('email', 'in', $authorlist);`

Must be `id` not email.

---

<div class="post-metadata">

**Author:** ![Peleke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/peleke/32/4935_2.png) [@Peleke](https://forum.getkirby.com/u/Peleke)\
**Post date:** [September 1, 2021, 9:25am UTC](https://forum.getkirby.com/t/list-of-authors-is-empty/23296/9 "2021-09-01T09:25:08Z")

</div>

Thanks, now it works as expected 🙂
