Authors' Links on Homepage Not Going to Author Post Pages

admin2025-04-15  0

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> 
Share Improve this question edited Dec 4, 2012 at 18:55 Abriel asked Nov 26, 2012 at 21:07 AbrielAbriel 1473 silver badges10 bronze badges 2
  • I was going to ask for the same code taht @Ralf912 did. Please post that. – s_ha_dum Commented Nov 26, 2012 at 21:32
  • @s_ha_dum added the code into my initial question – Abriel Commented Nov 26, 2012 at 22:03
Add a comment  | 

3 Answers 3

Reset to default 1

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>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744687006a261199.html

最新回复(0)