Forums

passing ID into the_author_posts_link ? (3 posts)

  1. sahaskatta
    Member
    Posted 1 year ago #

    Hey Everyone,
    I created a special template page so that I can list the members on a single page. I'm able to use the code below to get their name, website, and other meta information. However I can't seem to figure out a clean way to grab a link to each person's author archive (aka. the_author_posts_link).

    <?php $authors = array("clinton", "bush", "obama") ?>
    <?php foreach($authors as $author) : ?>
    
    <?php $user_info = get_userdatabylogin( $author ) ?> 
    
    <div class="person">
    <?php echo get_avatar( $user_info->user_email, '150' ); ?>
    <div class="details">
    <?php echo $user_info->display_name ?><br />
    <span><?php echo $user_info->user_email ?></span>
    </div>
    </div>
    
    <?php endforeach; ?>

    Using the_author_posts_link in that for loop isn't working. Everything else works perfectly. Can someone please offer me a suggestion to grab a link to a list of their posts. (not their website link.)

  2. Joseph
    Member
    Posted 1 year ago #

    the_author_posts_link() takes no arguments. It's meant ot be used inside the loop.

    There seems to be no function that output an author's archive link by id. However, since you know the author names and permalink structure, you can do the links yourself within the foreach loop.

  3. sahaskatta
    Member
    Posted 1 year ago #

    Thanks Joseph,
    Was just hoping there was an easier way. It would be a safer setup to have a function rather than hard coded URLs. If someone changes the permalink structure, it could entirely break.

    If anyone knows of another function that would work in the context I need that would be appreciated. As long as it accepts either an author name or ID, that would do the trick.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic