WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] list_authors()

[Resolved] list_authors()

  • 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)
  • whooami

    @whooami

    Member

    the codex page for the template tag you are using answers your question by showing the available parameters.

    http://codex.wordpress.org/Template_Tags/list_authors

    of which what you described is not one of them.

    whooami

    @whooami

    Member

    what you need to do is read this:

    http://codex.wordpress.org/Author_Templates

    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 = "http://{$_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.

    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 ‘[Resolved] list_authors()’ is closed to new replies.
Skip to toolbar