WordPress.org

Ready to get started?Download WordPress

Forums

get author name hack (2 posts)

  1. darkfate
    Member
    Posted 7 years ago #

    I found this out while messing around with my template. It only works when your using mod_rewrite:

    <?php if (is_author()) { ?>
    <h2><?php $expl = explode("/",$_SERVER["REQUEST_URI"]);
    $author = $expl[count($expl)-1];
    echo $author."'s Posts"; ?></h2>
    <?php } ?>

    Slightly ineffective, but it works if you have author/name and it will grab name.

  2. Kafkaesqui

    Posted 7 years ago #

    Actually, you can collect all sorts of 'author' data this way on an author query (and it should work no matter the permalink structure you use):

    <?php
    global $wp_query;
    $curauth = $wp_query->get_queried_object();
    ?>

    This shows the info you can then echo from the $curauth object:

    http://codex.wordpress.org/Author_Templates#About_Current_Author

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags