WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] list_authors() (6 posts)

  1. therealhopeful
    Member
    Posted 6 years ago #

    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.

  2. whooami
    Member
    Posted 6 years ago #

    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.

  3. whooami
    Member
    Posted 6 years ago #

    what you need to do is read this:

    http://codex.wordpress.org/Author_Templates

  4. therealhopeful
    Member
    Posted 6 years ago #

    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; ?>
  5. MichaelH
    Member
    Posted 6 years ago #

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

  6. therealhopeful
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic