• How does one make the author of a post show automatically for each post?

    I tried putting “the_author” tag in the index.php theme file, but it didn’t have the desired affect. Any suggestions?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Can you confirm that you placed the_author() inside your loop?

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <!-- some other xhtml template code could go here-->
    
    <p>This post was written by <?php the_author(); ?></p>
    
    <!-- some other xhtml template code could go here-->
    <?php endwhile; endif; ?>

    Can you post the code that you’re trying to change?

    Thread Starter bebob515

    (@bebob515)

    well, that’s just it … I don’t know what I’m trying to change, exactly. I’m just trying to make it so that the author of each post shows along with the date …. just the date shows now.

    I understand the concept of the loop, but don’t know which files affect it.

    I understand the concept of the loop, but don't know which files affect it.

    –Each template page can have its own (or many different) loop(s)…which makes WP really flexible, but also tricky sometimes to determine which file changes what page…

    Can you list the php files in your theme?

    For example:
    index.php
    archive.php
    single.php

    Also, on which page(s) are you trying to add the author name? All pages, just the home page, category page? (it’d probably also help if you could post a link to your site).

    Thread Starter bebob515

    (@bebob515)

    I’d like to have the author accompany all posts on all pages.

    The site I’m working on is teacherparent.org

    my php files are all in the default theme folder as follows:

    404
    archive
    archives
    comments-popup
    comments
    footer
    functions
    header
    image
    index
    links
    page
    screenshot
    search
    sidebar
    single

    Thanks for your help

    I'd like to have the author accompany all posts on all pages.

    You’ll need to change each of these files:
    index.php
    archive.php
    page.php
    single.php

    In index.php change:

    <small><?php the_time('F jS, Y') ?> </small>

    to

    <small><?php the_time('F jS, Y') ?>  by <?php the_author() ?></small>

    In archive.php change:

    <small><?php the_time('l, F jS, Y') ?></small>

    to

    <small><?php the_time('l, F jS, Y') ?>  by <?php the_author() ?></small>

    In page.php and single.php change:

    <h2><?php the_title(); ?></h2>

    to

    <h2><?php the_title(); ?></h2>
    <small>by <?php the_author() ?></small>

    Note that you can put any xhtml markup around <?php the_author(); ?> (not just <small> </small>)

    Thread Starter bebob515

    (@bebob515)

    Thanks jkovis …. that all worked …. appreciate the help

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘trying to add author to post’ is closed to new replies.