[wp-trac] Re: [WordPress Trac] #1969: Check for category and author page existence

WordPress Trac wp-trac at lists.automattic.com
Fri Feb 17 01:30:57 GMT 2006


#1969: Check for category and author page existence
-----------------------+----------------------------------------------------
       Id:  1969       |      Status:  reopened                
Component:  General    |    Modified:  Fri Feb 17 01:30:57 2006
 Severity:  normal     |   Milestone:  2.1                     
 Priority:  normal     |     Version:  2.0.1                   
    Owner:  anonymous  |    Reporter:  chuyskywalker           
-----------------------+----------------------------------------------------
Changes (by joelgilmore):

  * resolution:  fixed =>
  * milestone:  2.0 => 2.1
  * summary:  Empty categories return 404 instead of using archive.php =>
              Check for category and author page existence
  * version:  1.6 => 2.0.1
  * status:  closed => reopened

Comment:

 I think a better modification, which I can't see that this does, is to
 check whether the category (or author page) exists, and if so, go to it
 even if it has no posts.

 The appropriate code would be

 {{{
         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
 }}}


 This works very well on my <a href="http://www.dividingline.org/>site</a>,
 and also applies to author pages, since I display information about
 Subscribers as well as Contributors et al.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/1969>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list