WordPress.org

Ready to get started?Download WordPress

Forums

Add date and author's name (12 posts)

  1. beammeupscotty
    Member
    Posted 4 years ago #

    This has been probaly been asked many times- but how does one Add the date and author's name to a post ?

  2. kiano.ro
    Member
    Posted 4 years ago #

    Date and author are auto-added by your theme but only if it is coded this way...

  3. MichaelH
    Member
    Posted 4 years ago #

    The WordPress Default theme has an example of the_author in the wp-content/themes/default/index.php but the code is 'commented-out' so it doesn't execute. So if you wanted to display the author info with the WordPress Default theme you would change the line in wp-content/theme/default/index.php
    from:
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    to
    <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?> </small>

    Note the use of the template tag, the_author_posts_link(), which causes the author's name to be presented as a link to his/her posts.

    This also demonstrates the template tag, the_time(), which displays the date.

  4. Shane G
    Member
    Posted 4 years ago #

    Hi,

    To add Date and Time stamp in wordpress we need to modify index.php file of the current active theme. Please check the code here:

    Date and Time Code

    For author add this code in index.php file of your theme where you want to display the author name:

    <?php the_author() ?>

    Thanks,

    Shane G.

  5. beammeupscotty
    Member
    Posted 4 years ago #

    Hi MichaelH- did what you said, but it still doesn't show in the posts.....
    Plus this is my index.php file of the current active theme I am using

    <?php get_header(); ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post();
    $thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
    ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="pic fl">
    <?php if($thumb !== '') { ?><?php the_author() ?>
    " title="<?php the_title(); ?>"><img src="<?php echo $thumb; ?>" alt="<?php the_title(); ?>" />
    <?php } else { echo ''; } ?>
    </div>
    <p class="meta-nfo"><?php the_author_posts_link(); ?>  /  <?php the_category(', ') ?>  /  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
    <h2>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <div class="fix"></div>
    </div>

    <?php endwhile; ?>

    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

    <?php else : ?>

    <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif; ?>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

  6. MichaelH
    Member
    Posted 4 years ago #

    You have this code that may be causing it not to execute the code you entered:

    <?php if($thumb !== '') { ?><?php the_author() ?>

    So you might want to change the_author to the_author_posts_link and add the_time in there.

    If you continue this thread, please provide a link to see the problem.

  7. beammeupscotty
    Member
    Posted 4 years ago #

    Okay- did what you said and still not working- heres the code

    <?php get_header(); ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post();
    $thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
    ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="pic fl">
    <?php if($thumb !== '') { ?><?php the_author_posts_link() ?><?php the_time('F jS, Y') ?>
    " title="<?php the_title(); ?>"><img src="<?php echo $thumb; ?>" alt="<?php the_title(); ?>" />

    <?php } else { echo ''; } ?>
    </div>
    <p class="meta-nfo"><?php the_author_posts_link(); ?>  /  <?php the_category(', ') ?>  /  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
    <h2>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <div class="fix"></div>
    </div>

    <?php endwhile; ?>

    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

    <?php else : ?>

    <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif; ?>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    And heres the link

  8. beammeupscotty
    Member
    Posted 4 years ago #

    Didn't let me post that link........so heres the address
    http://www.addictivehobby.com/wordpress/

  9. MichaelH
    Member
    Posted 4 years ago #

    Looks okay to me.

    admin  /  Uncategorized  /  1 Comment
  10. beammeupscotty
    Member
    Posted 4 years ago #

    I am trying to get the date and Authors name like this
    http://psd.tutsplus.com/
    The red bit !

  11. MichaelH
    Member
    Posted 4 years ago #

    So rearrange things so it's like:

    the_time  the_category  the_author_posts_link

    Review the_time() and Formatting_Date_and_Time

  12. an52
    Member
    Posted 4 years ago #

    I'd like to add the author's Name, not Username. Those are the labels used in the User dialog.

    e.g. If Joe Blow is the Name and joe1982 is his Username, the_author displays joe1982 which is not very useful. Is there any way to show his Name? I have a site with several contributing authors, so showing their real names with the post is better than revealing their login names.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.