get author name hack (2 posts)

  1. darkfate
    Posted 9 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 9 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):

    global $wp_query;
    $curauth = $wp_query->get_queried_object();

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


Topic Closed

This topic has been closed to new replies.

About this Topic