WordPress.org

Ready to get started?Download WordPress

Forums

trying to add author to post (7 posts)

  1. bebob515
    Member
    Posted 4 years ago #

    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?

  2. jkovis
    Member
    Posted 4 years ago #

    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?

  3. bebob515
    Member
    Posted 4 years ago #

    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.

  4. jkovis
    Member
    Posted 4 years ago #

    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).

  5. bebob515
    Member
    Posted 4 years ago #

    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

  6. jkovis
    Member
    Posted 4 years ago #

    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>)

  7. bebob515
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic