wordpress

wp echo the_author_link(); fail to author.php


I wrote the code <?php echo the_author_link(); ?> on theme/xtocky/woocommerce/centent-product.php

It output the link like <a href="www.dermaroller.com">zac1987</a>.

How to make it output the link like <a href="author.php">zac1987</a>?

I have created author.php file on both xtocky folder and woocommerce folder, I thought <?php echo the_author_link(); ?> will automatic create link to author.php but why it doesn't?


Solution

  • Found the solution, just replace my code with <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author(); ?></a>

    Don't know why cannot use the_author_link();. Maybe any expert can explain in future.

    UPDATE

    Sorry, the correct answer is replace the_author_link(); with the_author_posts_link();