[wp-trac] [WordPress Trac] #26749: Post Type archive incorrectly identified as "home"

WordPress Trac noreply at wordpress.org
Mon Dec 30 22:45:00 UTC 2013


#26749: Post Type archive incorrectly identified as "home"
--------------------------+-----------------------------
 Reporter:  michaelhall   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.8
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 == Issue ==
 If you go to a post type archive via GET parameters
 ("?post_type[]=post&post_type[]=page"), then the WP_Query incorrectly
 identifies the location as home.

 == Reason fix is required ==
 Causes incorrect templates to be used in some themes.

 == Steps to reproduce ==
 1. Setup wordpress
 2. Add the following to your theme functions file
    {{{#!php
    add_action('init', function () {
        // allow archives on the main post types
        global $wp_post_types;

        $wp_post_types['post']->has_archive = true;
        $wp_post_types['page']->has_archive = true;
    });
    add_action('parse_query', function(&$query) {
        // just testing for information
        if ($query->is_main_query()) {
            var_dump($query);
        }
    });
    }}}
 3. Go to your wordpress home in your browser
 4. Add "?post_type[]=post&post_type[]=page"
    * Note that this works for any post types
    * Also note that "has_archive" on the post types does not matter

 === Expected Results ===
 * "is_home" is set to false
 * "is_archive" is set to true
 * "is_post_type_archive" is set to true

 === Actual Results ===
 * "is_home" is set to true
 * "is_archive" is set to false
 * "is_post_type_archive" is set to false


 == Other Notes ==
 * The "post" type has "has_archive" set to false by default, should
 consider changing it to true
 * If a single post_type is set in the URL that has "has_archive" set to
 false, then the template is the home page, but the query uses the selected
 post_type anyway
   * eg. Go to homepage with posts feed, then add "?post_type=page", the
 homepage will then give a feed of pages instead of posts

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


More information about the wp-trac mailing list