• Resolved daschan

    (@daschan)


    Sorry, I’m a newbie. I have read the codex “Template Tags/the author”, “The Loop in Action” and “The Loop”.

    So I went into my C-panel, opened the wordpress directory, and opened the index.php file to edit it, thinking to simply insert <?php the_author(idmode='', echo); ?> into the loop.

    But this is what I found in the index.php file:

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    So where is The Loop?? Help! I tried opening up the file wp-blog-header.php to see if somehow or other The Loop was there, but I couldn’t at all find the line <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> nor even the line <?php endwhile; else: ?>

    I want to display the author’s nickname on every post, because this blog has a number of authors, and every one of us is just too lazy to type our names beneath the titles.

    Thanks in advance.–D. Chan

    I’m using the theme Georgia.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The main index.php file in your root wordpress directory is not really supposed to be edited or so .. ??

    What you want to edit to do what you want is, go into ‘wp-content’ directory, and then ‘themes’, and then the theme directory, in your case ‘Georgia’ or whatever it is named.

    Inside this directory you will find another index.php file, this is the file that you edit.

    Take a shot, if you have more trouble, post another message. ??

    Thread Starter daschan

    (@daschan)

    Thanks again. I see what appears to be The Loop, although it is not exactly as given in the codex.

    Is this it? (sorry, I’m not going to post the entire text of the index.php file–much too long, and as it is, this is long enough.)

    <div id="content">
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h3>

    <div class="storycontent">
    <?php the_content(); ?>
    </div>

    <div class="meta"><?php the_date(); ?> <?php the_time() ?> | <?php _e("Filed under:"); ?> <?php the_category() ?> | <?php edit_post_link(); ?>
    <span class="feedback"><?php wp_link_pages(); ?><?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> </span>
    </div>

    <!--
    <?php trackback_rdf(); ?>
    -->
    <?php if ($single) { comments_template(); } ?>
    </div> <!-- End Post -->
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    </div> <!-- End Content -->

    From the looks of it, I’ll insert the <?php the_author(idmode='', echo); ?> right after the code for the story title (or wherever I want to fit it), right?

    I haven’t tried it out yet. Please let me know first if I’m on the right track.

    You’ve got the right part. ??

    Inserting <?php the_author(idmode=”, echo); ?> anywhere before this part:


    </div> <!– End Post –>
    <?php endforeach; else: ?>

    Will display the author according the arguments that you are passing.

    Let me know if it works out good.

    Thread Starter daschan

    (@daschan)

    Sorry to get back so much later. In the middle of my reply post late last night (early morning my time, actually), this forum was moved to another server, and my post was lost. Neither could I access the forum even 1/2 hr later.

    I ran into a wee problem when I inserted this code: <?php the_author(idmode='', echo); ?> into The Loop. When I went to the blog site, there was only a message that there was a parsing error, a problem with ‘=’, or some such.

    Okay, so I don’t know PHP! ??

    Anyway, it’s fixed now and works just fine. I used this code instead (after re-reading the codex referred to above): <?php the_author(''); ?>. This allows the post to display the author’s nickname.

    Thought I should spell it out clearly here for others who also might be new at PHP and WP.

    Thanks for all your help, Skulled!

    Sorry actually that was my bad .. I forgot to mention that ..

    Under normal circumstances when you are sending arguments to template tag/functions you do not use the variable name part.

    I should have noticed that and mentioned it ..

    Apologies for have missed that ..

    Yep. Should be something like:

    <?php the_author(); ?>

    or

    <?php the_author('namefl'); ?>

    or

    <?php the_author('nickname', TRUE); ?>

    See the Codex page on this template tag for more:

    https://codex.www.ads-software.com/Template_Tags/the_author

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘display author’s name on post’ is closed to new replies.