WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help Please For Code To Add Author's Names To Posts (10 posts)

  1. marcbkk
    Member
    Posted 6 years ago #

    I am using the Cut Line theme and I have edited my theme's index.php file with the following code in order to show author's names on blog posts on the front page of the site:

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

    The problem is that when someone reads a blog post from either one of the category pages or goes to the page to add a comment onto the post, then the original author's name of the post no longer appears.

    I assume I need to edit the code within some of the other php files within the theme in order to affect these other pages too.

    Can anyone please advise what code I should change and on which php pages of the theme?

    Many thanks.

  2. whistler2020
    Member
    Posted 6 years ago #

    look in you theme folder for a file named single.php or something similar

  3. marcbkk
    Member
    Posted 6 years ago #

    Thanks. Do you think that will cover all other site pages within the theme if I edit that one too?

  4. whistler2020
    Member
    Posted 6 years ago #

    it should if you dont have any templates setup

  5. marcbkk
    Member
    Posted 6 years ago #

    Thanks, I edited the file named single.php by using the following code string:

    <h4><?php the_time('F jS, Y') ?> by <?php the_author() ?> --> <?php comments_number('No Comments', '1 Comment', '% Comments'); ?></h4>

    This has sorted out showing of the author's name in all expanded post screens where people can add in comments.

    What is still not showing the author's name though are the category pages where it shows a summary of each post within that category.

    Not sure where I have to edit the code to affect showing authors name's on posts within the categories.

    Thanks?

  6. soyuz
    Member
    Posted 6 years ago #

    you can check the archive.php and category.php if your theme has it.

  7. marcbkk
    Member
    Posted 6 years ago #

    Thanks. I edited the archive.php file too (no have category.php) and that has done it. Great. You are a life saver.

  8. soyuz
    Member
    Posted 6 years ago #

    cool :D

    maybe you can change this topic to "resolved"

  9. frioman
    Member
    Posted 5 years ago #

    I was successful in editing my index.php to display "by XXXXXX". "X" equals author display name. That was my first time at this; however, now I want to do what the member above did. I want the author display name to display on all their posts, even when not on the main page, i.e. in archives. Thanks in advance for any help you can provide.

    Please try to be specific. I'm reading what I can on this, but I'm hesitant to change code without being certain if it's the correct line.

  10. frioman
    Member
    Posted 5 years ago #

    I solved the problem. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic