WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to get author's name on posts (automatically)? (6 posts)

  1. wickedwidget
    Member
    Posted 5 years ago #

    Hi
    I've just set up a blog - I'm the administrator and I've added one contributor.

    Is there a way of configuring the blog so that the author's name appears below the post (next to / under categories etc)?

  2. stvwlf
    Member
    Posted 5 years ago #

    You have to add some code to the template pages.

    Something like this

    <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    	<p align="right"><b>By <?php the_author(); ?></b> | <?php the_time('F j, Y'); ?></p>
  3. Shane G
    Member
    Posted 5 years ago #

    Hi,

    You need to add author tag code in page.php file of your wordpress theme..

    This is an example of code which needs to be add:

    <?php
    include (TEMPLATEPATH, "/author.php");
    ?>

    That's it!

    Thanks,

    Shane G.

  4. wickedwidget
    Member
    Posted 5 years ago #

    Hi - I tried adding code to page.php but nothing happened -

    then I dug around in index.php and saw <?php the_author() ?> was commented out - so I uncommented and author's name appeared...

    bit puzzled that the page.php didn't react at all to my changes - I actually added a new div with background red, height 100px etc to check whether changes were registering - and they weren't -mystifying stuff

    but thanks for pointing me in right direction

    cheers
    Chris N

  5. t31os
    Member
    Posted 5 years ago #

    page.php applies to when you are viewing a Page
    single.php (or index if one doesn't exist) applies when viewing a single post

    stvwlf had the solution, and Shane seemed to sidetrack off to something else...

    <?php
    include (TEMPLATEPATH, "/author.php");
    ?>

    Will do nothing if the theme doesn't have an author.php file...

    Author pages are not what was asked for, so i'm totally baffled why it was suggested anyway.

    You're all sorted now anyway, so no matter... :-)

  6. jockpost
    Member
    Posted 4 years ago #

    I changed it in index.php and page.php here (snippet):

    <div class="postmetadata">Posted by <?php the_author(', ') ?> | <?php the_time('F jS, Y') ?></div>

    I guess it may depend on the theme you are using. But if you see a spot that has the_category in the code and you would like to replace it with the author name, then replace the_category with the_author in any page you wish.

Topic Closed

This topic has been closed to new replies.

About this Topic