Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This problem only occurs with the articles/blog posts on the homepage of the site, readbuzz.com.

On the homepage of the site, the author's name is supposed to link to that particular author's post page, where all the blog posts the author posted on the website will show up. Instead, each name that shows up links to the homepage.

Yet, when you click and go into any of the posts on the homepage, then checked the author's link, it takes you directly to that author's post page.

I know I need to include this function, but can't seem to find the place where I need to edit this: link

UPDATE: The code below is the correct code, in several different PHP files. Currently need to know how to write it using the the_author_posts_link();

<p class="postAuthor">By <a href="<?php the_author_meta('user_url'); ?>"><?php the_author(); ?></a></p> 
share|improve this question
    
I was going to ask for the same code taht @Ralf912 did. Please post that. –  s_ha_dum Nov 26 '12 at 21:32
    
@s_ha_dum added the code into my initial question –  Abriel Nov 26 '12 at 22:03

2 Answers 2

up vote 1 down vote accepted

The code below is the correct code, in several different PHP files. Currently need to know how to write it using the the_author_posts_link();

<p class="postAuthor">By <a href="<?php the_author_meta('user_url'); ?>"><?php the_author(); ?></a></p>

Just replace this:

<a href="<?php the_author_meta('user_url'); ?>"><?php the_author(); ?></a>

With this:

<?php the_author_posts_link(); ?>

Alternately, you could use this:

<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author(); ?></a>

Codex references:

share|improve this answer
    
Thank you very much! :) We must've figured that out at the same time because I was in the middle of putting this up as an answer, but you made it much clearer than I would've in explaining it. –  Abriel Dec 4 '12 at 19:23

Look in the source code of your homepage. You will see that all links are empty:

<a href="">Melissa Espana</a>

Please post the php code which will create the html link. This failure often caused by a forgotten echo. E.g.:

<?php
$foo = 'http://www.example.com/author';
?> <a href="<?php esc_attr( $foo ); ?>"><?php echo author_name(); ?></a><?php

In this case esc_attr( $foo ); only escaped $foo but did not output the result.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.