1

currently, this example code in WordPress:

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

turns into:

<a href="http://example.com/author/user-name">user-name</a>

If the link is click, it will take the visitor to the author's page and use the "author.php" template file from the current theme to display the page.

How do I get another custom link, something like this:

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

to use "custom-author-file.php"?

1 Answer 1

1

In author.php:

<?php
get_template_part('custom-author-file');

Alternatively, rename your custom-author-file.php to author.php.

The URL being used in this case isn't relevant, as a template doesn't determine the URL used, it's the other way around. However, I suspect there is more to your question you haven't explained

4
  • Basically, I'm trying to make 2 "author.php" theme file for all authors, not a specific author. One of the author.php file will have most element stripped down and be loaded onto a page by ajax when someone click on an author link. The other one will have no modification at all just so the web search engines can find the authors and index them.
    – lee
    May 4, 2016 at 6:01
  • hmm so your actual problem is you want to load an author archive via AJAX but without the header and footer? You should have asked that in the first place!
    – Tom J Nowell
    May 6, 2016 at 1:04
  • Yeah, that's what I'm trying to achieve. I already got help from here: stackoverflow.com/questions/37020646/…
    – lee
    May 6, 2016 at 6:39
  • You need to rewrite your question to ask that, you have what we call an XY problem where you devise a solution Y for problem X, then ask about Y, rather than the original problem
    – Tom J Nowell
    May 6, 2016 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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