• I would like to display the members username in a post. Does anyone know how I could do this?

    Many thanks,

    Will

Viewing 6 replies - 1 through 6 (of 6 total)
  • <?php the_author_posts_link(); ?>
    to make it a link to all posts by that author

    or
    <?php the_author(); ?>
    to just display the name

    Thread Starter gamesmad

    (@gamesmad)

    This code is not working when I add it to the page. Just to clarify, I am doing this through wp-admin/page.php Is that possible?

    Cheers,

    Will

    Thread Starter gamesmad

    (@gamesmad)

    OK, update, I have installed a plugin that allows me to use PHP, so the code does now work.

    However, it is the wrong code, I need the user who is READING the posts username. To say, Hey, USERNAME, kinda thing.

    Can anyone help please?

    Will

    You could try something like:

    <?php if(is_user_logged_in() )  :?>
    <p>Hey <?php echo $user_identity; ?></p>
    <?php endif;?>
    Thread Starter gamesmad

    (@gamesmad)

    That code did not work, found something on a wiki that works though –

    global $current_user;
          get_currentuserinfo();
    
          echo ' . $current_user->user_login . ';

    Hopefully that helps anyone else that needs it.

    I am integrating the users username into a URL, is there any way I can stop WordPress from adding my blogs url to the beginning of the url? Its doing this –

    http://www.myurl.com/http://www.url-its-suppose-to-be.com

    Cheers,

    Will

    You’ll have to generate a full, absolute, url.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘How to display a username’ is closed to new replies.