diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 50d3638bdf..84111bca9f 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -261,9 +261,11 @@ class WP { */ $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars ); - foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) - if ( $t->query_var ) + foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) { + if ( is_post_type_viewable( $t ) && $t->query_var ) { $post_type_query_vars[$t->query_var] = $post_type; + } + } foreach ( $this->public_query_vars as $wpvar ) { if ( isset( $this->extra_query_vars[$wpvar] ) ) diff --git a/wp-includes/post-functions.php b/wp-includes/post-functions.php index 6e1d0e3742..2d9f90960c 100644 --- a/wp-includes/post-functions.php +++ b/wp-includes/post-functions.php @@ -1072,12 +1072,15 @@ function register_post_type( $post_type, $args = array() ) { add_post_type_support( $post_type, array( 'title', 'editor' ) ); } - if ( false !== $args->query_var && ! empty( $wp ) ) { + if ( false !== $args->query_var ) { if ( true === $args->query_var ) $args->query_var = $post_type; else $args->query_var = sanitize_title_with_dashes( $args->query_var ); - $wp->add_query_var( $args->query_var ); + + if ( $wp && is_post_type_viewable( $args ) ) { + $wp->add_query_var( $args->query_var ); + } } if ( false !== $args->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c84d761c17..e8919da8ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34214'; +$wp_version = '4.4-alpha-34215'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.