• When I view a post at the bottom is a link “all articles from this author” which if clicked pulls up a page not found error using a URL shown as domain.com/author/tony (note tony is the nickname for admin who is the author). After hours of researching, I came across the following scenario that relates to the above problem.

    At the top of every post I write there is a field that lists the author (the nickname is tony but it populates admin). If I click on that it then pulls up every post related to admin (not by the nickname tony) and uses a URL as domain.com/?author=1

    So if I find articles by author name it works but by nickname it does not work (changing nickname to name doesn’t fix the problem).

    Thanks for any help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Gan you provide a link to your site?

    If ?author=1 works but /author/tony doesn’t, it might be because your permalinks aren’t set up. Go to Settings > Permalinks and make sure you have one of the pretty options selected (ex: Month and Day).

    Thread Starter iselltheta

    (@iselltheta)

    Thanks for the quick response. The site is macrostory.com

    I tried changing the permalinks (was on custom). I tried a few and it still returns the page not found error but this time the page not found is inside my theme versus the original error was from my host.

    The issue is that it’s using the display name for generating the link rather than the username. The display name can be set to anything, but the username is fixed and used for the author archive page.

    See if you can find where in the theme that block at the bottom of the posts is being generated. Most likely you’ll find it in single.php. Look at what’s using to generate that link. I’m guessing it’s hard-coded to be “>

    This should be changed to “>

    Oops, it didn’t like that I put code in there.

    Change from:
    <a href="/author/<?php the_author();?>">

    To:
    <a href="<?php echo get_author_posts_url;?>">

    Thread Starter iselltheta

    (@iselltheta)

    I found where the link is generated (it was in single.php) but the code is a little different so before I change something I wanted to confirm how it should be changed. The problem link is for “all articles from this author.” Here is the current code:

    <div class=”author-details”>” target=”_blank”>Visit Authors Website  |  /author/<?php echo strtolower(get_the_author_nickname()); ?>”>All Articles From This Author</div>
    </div>

    Thank You!

    While the code’s a bit broken (use the code button to post code) I was right in my assumption that they were using the display name rather than the username. Replace
    <a href="/author/<?php echo strtolower(get_the_author_nickname());?>">

    With
    <a href="<?php echo get_author_posts_url();?>">

    Thread Starter iselltheta

    (@iselltheta)

    I’m going to send the original code again because it’s slightly different in terms of what I am changing. Here is how the code currently reads. Thank You

    <div class="author-details"><a href="<?php the_author_url(); ?>" target="_blank">Visit Authors Website</a> &nbsp;|&nbsp; <a href="<?php bloginfo('url'); ?>/author/<?php echo strtolower(get_the_author_nickname()); ?>">All Articles From This Author</a></div>
              </div>

    Use this:

    <div class="author-details"><a href="<?php the_author_url(); ?>" target="_blank">Visit Authors Website</a> &nbsp;|&nbsp; <a href="<?php echo get_author_posts_url(); ?>">All Articles From This Author</a></div>
              </div>

    Thread Starter iselltheta

    (@iselltheta)

    I just tried it and I still get the page not found message. The URL populates with a really long address as shown below.

    https://macrostory.com/%3Cbr%20/%3E%3Cb%3EWarning%3C/b%3E:%20%20Missing%20argument%201%20for%20get_author_posts_url(),%20called%20in%20/home/content/67/7476167/html/wp-content/themes/cleanone/cleanone/single.php%20on%20line%2063%20and%20defined%20in%20%3Cb%3E/home/content/67/7476167/html/wp-includes/author-template.php%3C/b%3E%20on%20line%20%3Cb%3E220%3C/b%3E%3Cbr%20/%3Ehttps://macrostory.com/?author=0

    Sorry about that, I thought it would automatically pick up the author ID but it needs you to explicitly state it.

    Here’s the updated code

    <div class="author-details"><a href="<?php the_author_url(); ?>" target="_blank">Visit Authors Website</a> &nbsp;|&nbsp; <a href="<?php $id = get_the_author_meta('ID'); echo get_author_posts_url($id); ?>">All Articles From This Author</a></div>
              </div>

    I’ve tested it this time ??

    Thread Starter iselltheta

    (@iselltheta)

    You are the MAN! Thank you very much for all of your help…. I owe you a beer…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Author related posts generates page not found error’ is closed to new replies.