• Resolved therealhopeful

    (@therealhopeful)


    Is there a way to get list_authors (or another WordPress API to put user-defined text/code before and after each list item it generates? I would like to generate a page that lists out the authors and puts a picture and some info about each of them. I would rather not use a hack to do this, if I don’t have to. Currently, I’m using this code to generate the list of authors, but I’m at a loss for where to go next.

    <?php list_authors(FALSE,TRUE,TRUE,TRUE) ?>

    Any suggestions would be greatly appreciated. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • the codex page for the template tag you are using answers your question by showing the available parameters.

    https://codex.www.ads-software.com/Template_Tags/list_authors

    of which what you described is not one of them.

    what you need to do is read this:

    https://codex.www.ads-software.com/Author_Templates

    Thread Starter therealhopeful

    (@therealhopeful)

    Hello Dr. Who. Thanks for the pointer! It was very helpful. I decided to change how I’m going about this a little bit. As you can see in the code below, I’m now using PHP to pull the author pic, if it exists. However, for some reason file_exists() keeps returning FALSE when I know for a fact the file is there. Any thoughts?

    <?php
      if(isset($_GET['author_name'])) :
        $curauth = get_userdatabylogin($author_name); // NOTE: 2.0 bug requires get_userdatabylogin(get_the_author_login());
      else :
        $curauth = get_userdata(intval($author));
      endif;
    ?>
    
    ...
    
        <?php
          $filepath = "https://{$_SERVER['HTTP_HOST']}/wp/wp-content/uploads/authors/{$curauth->user_login}.jpg";
          if (file_exists($filepath)) : ?>
            <img class="photo" src="<?php echo $filepath ?>" alt="<?php echo $curauth->display_name; ?>, <?php echo $curauth->nickname; ?>" />
        <?php else : ?>
          <?php echo '' ?>
        <?php endif; ?>

    Try an echo $filepath right after you set the value to see if it’s what you expect.

    Thread Starter therealhopeful

    (@therealhopeful)

    Thanks for the help! I was able to get this working using the Cimy Extra User Fields plugin. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘list_authors()’ is closed to new replies.