Newbie : getting author name in loop on home page

Hi there, I’m totally new at Kirby, used to work with Wordpress, I’m struggling to get the author name in the for each loop on the home page of my blog. Any idea ?

My folder structure looks like this : https://infinit.io/_/6WpWwVt

What I do so far is :

<?php $author = $pages->find('authors')->children() ?>

and then <?php echo $author->name() ?>

I’m confused bc <?php echo $author ?> gives me authors/john-doe
I have put the name: john-doe in author.txt but I get nothing with <?php echo $author->name() ?>

Thanks!

I’m not quite sure what you want to achieve? Do you want to list all author names in $author? If so (assuming that the title field contains the name of the author):

<?php

$authors = page('authors')->children();
foreach($authors as $author) {
  echo $author->title();  //or whatever field contains the author's name
}
?>
1 Like