WordPress.org

Ready to get started?Download WordPress

Forums

How to add "Posted by 'author'" at the top of the post content (12 posts)

  1. abdulbasitsaeed
    Member
    Posted 5 years ago #

    Hi there, everyone.

    I'm using the "StudioPress Green Theme" on my blog and it doesn't display the text "Posted by 'author name'" at the top of the entry. I have tried adding the <?php the_author(); ?> tag, but didn't get any results.

    The code for my index.php is as follows:

    <?php get_header(); ?>
    
    <div id="contentwrapper"><div id="content">
    
    <div class="adsense_top"><?php include (TEMPLATEPATH . '/adsense_top.php'); ?></div>
    
    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post">
    <h2 class="postTitle"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <div class="postMeta">
    <span class="date"><?php the_time('M.d, Y') ?></span> in
    <span class="filed"><?php the_category(', '); ?></span>
    </div>
    <div class="postContent"><?php the_content('[Read the rest of this entry...]'); ?></div>
    <p class="comments"><?php comments_popup_link('Leave a Comment', 'Comments (1)', 'Comments (%)'); ?>
    
    </div> <!-- Closes Post -->
    
    <?php endwhile; ?>
    
    <?php else : ?>
    
    <div class="post">
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.
    
    </div> <!-- Closes Post -->
    
    <?php endif; ?>
    
    <div id="nextprevious">
     <div class="left"><?php posts_nav_link('','','&laquo; previous entries') ?>&nbsp;&nbsp;</div>
     <div class="right"><?php posts_nav_link('','next entries &raquo;','') ?></div>
    </div>
    
    </div></div> <!-- Closes Content -->
    
    <?php get_sidebar(); ?>
    
    <div class="cleared"></div>
    
    </div> <!-- Closes Main -->
    
    <?php get_footer(); ?>

    The address is http://www.blog.pakfellows.com. I would be extremely grateful if anyone were to help me out as to where do I need to make changes and in which files.

    Thanks a ton!

  2. tsguitar
    Member
    Posted 5 years ago #

    Wait, wait... is that the code in your index.php file or your Main Index Template file? Are you using the WordPress Theme Editor to edit your templates? If so, that should be the Main Index Template, right?

    the_author should work:
    http://codex.wordpress.org/Template_Tags/the_author

    There are two things I can think of: do you have a public name in your author profile? Just login and click on your name in the upper right corner. Also, did you include your reference to the_author in The Loop?

    Put the_author back into your template and let us see it not working. Very strange...

  3. abdulbasitsaeed
    Member
    Posted 5 years ago #

    Thank you for responding, tsguitar.

    I thought that the index.php file itself is the Main Index Template, isn't it? Yes, I am using the Theme Editor to edit it, and that's how it shows it: Main Index Template (index.php)

    Yes, I do have a public name, as per your instructions and have set my nick to be displayed as well.

    I have entered the the_author tag once again in the code. The code is now as follows, after adding "<!-- Posted by <?php the_author(); on ?> -->" after <div class="postMeta">:

    <div class="post">
    <h2 class="postTitle"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <div class="postMeta">
    <!-- Posted by <?php the_author(); on ?> -->
    <span class="date"><?php the_time('M.d, Y') ?></span> in
    <span class="filed"><?php the_category(', '); ?></span>
    </div>
    <div class="postContent"><?php the_content('[Read the rest of this entry...]'); ?></div>
    <p class="comments"><?php comments_popup_link('Leave a Comment', 'Comments (1)', 'Comments (%)'); ?>
    
    </div> <!-- Closes Post -->

    Another strange thing is that where it says <span class="date"><?php the_time('M.d, Y') ?></span> in, if I replace in with any other text, e.g. in the category, it doesn't change it on the main page either.

    I think I may be missing some change in code which needs to be made to some other file. If it helps, other .php files with this theme include:

    # Archives (archive.php)
    # comments-original.php (comments-original.php)
    # Comments (comments.php)
    # Footer (footer.php)
    # Theme Functions (functions.php)
    # Header (header.php)
    # home.php (home.php)
    # Main Index Template (index.php)
    # Page Template (page.php)
    # Search Form (searchform.php)
    # Sidebar (sidebar.php)
    # Single Post (single.php)

    Hope you can understand the situation better now. :-)

  4. DianeV
    Member
    Posted 5 years ago #

    Sorry. Oops.

  5. tsguitar
    Member
    Posted 5 years ago #

    Oh. You have the author tag commented out and you've included some text inside the PHP tags that's probably causing some trouble. Here's what it should look like:

    <div class="postMeta">
    Posted by <?php the_author(); ?> on
    <span class="date"><?php the_time('M.d, Y') ?></span> in

    That should take care of your problems. Just remember that anything surrounded with <!-- and --> is a comment and will not display.

  6. abdulbasitsaeed
    Member
    Posted 5 years ago #

    Oops, my bad!

    Well, I made the change as above to the index.php file via the Theme Editor, but apparently, the problem is still there. :s

    http://www.blog.pakfellows.com

    Any ideas?

  7. abdulbasitsaeed
    Member
    Posted 5 years ago #

    Guess what, even when I completely delete

    <span class="date"><?php the_time('M.d, Y') ?></span> in
    <span class="filed"><?php the_category(', '); ?></span>

    from index.php, it still displays it! I don't know from where is it fetching this tag?!

    I realize this may be asking too much, but there is a link to the theme I'm using at the bottom of my page - in case anyone would be willing to put in a very generous effort in solving this mystery. I'd be obliged for ever.

  8. tsguitar
    Member
    Posted 5 years ago #

    You need to find out what template is being used for your home page. Try switching to the default theme and making changes to Main Index Template. You should be able to see those changes on your home page. Post back when you've tried that.

    Make sure you clear your browser cache!

  9. abdulbasitsaeed
    Member
    Posted 5 years ago #

    Well, I tried everything you asked me to do, my friend. I deleted all themes from the server, except for the default and classic. Then I re-uploaded the theme of my choice.

    When I edited the index.php of the default, everything works like magic. However, I simply can't detect which file to edit to bring about those same changes in my theme. I've tried editing index.php, single.php, post.php, home.php but without any results.

    And yeah, I also cleared by browser cache.

    I am literally at my wit's end over this. Any clue as to what to do?

  10. tsguitar
    Member
    Posted 5 years ago #

    Go back to using the default theme and see if you can make changes that appear on your home page. We'll get to the theme of your choice later. Right now, let's just make sure that you're set up to edit pages through WordPress and using the default theme is the best way to make sure of that.

  11. abdulbasitsaeed
    Member
    Posted 5 years ago #

    I see. Well, I changed it back to the default theme and as you can see, I have changed the text "Posted in" to "Posted in (testing changes in default theme)". I made these changes via the Theme Editor.

    How would you suggest proceeding from here, oh wise one! :)

  12. tsguitar
    Member
    Posted 5 years ago #

    I don't see the change to "Posted in (testing changes...". Did you make that change and already see that it works or something? I still see your site using StudioPress green theme.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.