• Hi all,

    Another question on author pages: I can access author pages for those with posts via blah.com/author/bob, for example. This works fine, as long as that author has at least one post. It won’t, however, work for anyone who hasn’t yet posted. Is this an intentional behaviour, or is it a bug? Has anyone else noticed it?

    I can still access their pages through blah.com/?author=3 or blah.com/?author_name=Bob.

    Cheers,
    Joel

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter joelgilmore

    (@joelgilmore)

    If you want something done right, you have to do it yourself! I hacked classes.php, and the handle_404 function right at the end, so that if a category or an author currently has no posts associated with it, it still gives me that page (author.php or category.php). The ammended code is:

    if (is_author() || is_category()){
    if ((!$wp_query->get_queried_object()) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    $wp_query->set_404();
    status_header( 404 );
    } elseif( is_404() != true ) {
    status_header( 200 );
    }
    } else { // If not in an author or category page
    if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    $wp_query->set_404();
    status_header( 404 );
    } elseif( is_404() != true ) {
    status_header( 200 );
    }
    }// End author/cat select

    Just replace the single if statement with this double pack. Apologies for lack of indents, I can work out how to do that in this comment.

    Also, can someone tell me where I should submit these fixes/upgrades/whatever so that they don’t get buried?

    Joel, thanks for the info. Unfortunately, I’m having trouble. Is the code you wrote supposed to replace this entire statement:


    if ( is_single() || is_page() ) {
    $GLOBALS['more'] = 1;
    $GLOBALS['single'] = 1;
    }

    Thanks again!

    If you look carefully you’ll see his code replaces all the code inside the handle_404 function near the bottom of classes.php

    Very good work, they should fix the “bug” in WP however that doesn’t allow “empty” categories and “empty” authors (or just users with only comments and not allowed to post)

    This solves it for the meanwhile.
    Off to make a decent authors.php page

    (thought I found the direct fix for 2.1a2 but I was wrong)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Previous posts required for author page link’ is closed to new replies.