This problem only occurs with the articles/blog posts on the homepage of the site, readbuzz.
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>
This problem only occurs with the articles/blog posts on the homepage of the site, readbuzz.
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>
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:
the_author_posts_link()
get_author_posts_url()
get_the_author_meta()
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/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.
I used the following to display the authors avatar, which links to the authors blog page, and displays the authors name on hover.
<a href="<?php
echo get_author_posts_url(get_the_author_meta( 'ID' ));
?>" title="<?php
the_author();
?>"><?php
echo get_avatar( get_the_author_meta( 'ID' ));
?></a>