mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Custom post type archives. see #13818.
git-svn-id: https://develop.svn.wordpress.org/trunk@15803 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -102,16 +102,22 @@ function wp_reset_postdata() {
|
||||
*
|
||||
* Month, Year, Category, Author, ...
|
||||
*
|
||||
* If the $post_types parameter is specified, this function will additionally
|
||||
* check if the query is for exactly one of the post types specified. If a plugin
|
||||
* is causing multiple post types to appear in the query, specifying a post type
|
||||
* will cause this check to return false.
|
||||
*
|
||||
* @see WP_Query::is_archive()
|
||||
* @since 1.5.0
|
||||
* @uses $wp_query
|
||||
*
|
||||
* @param mixed $post_types Optional. Post type or array of post types
|
||||
* @return bool
|
||||
*/
|
||||
function is_archive() {
|
||||
function is_archive( $post_types = '' ) {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_archive();
|
||||
return $wp_query->is_archive( $post_types );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1297,11 +1303,13 @@ class WP_Query extends WP_Object_Query {
|
||||
$this->is_author = true;
|
||||
}
|
||||
|
||||
if ( '' != $qv['author_name'] ) {
|
||||
if ( '' != $qv['author_name'] )
|
||||
$this->is_author = true;
|
||||
}
|
||||
|
||||
if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) )
|
||||
if ( !empty( $qv['post_type'] ) )
|
||||
$this->is_archive = true;
|
||||
|
||||
if ( $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax )
|
||||
$this->is_archive = true;
|
||||
}
|
||||
|
||||
@@ -2605,12 +2613,26 @@ class WP_Query extends WP_Object_Query {
|
||||
*
|
||||
* Month, Year, Category, Author, ...
|
||||
*
|
||||
* If the $post_types parameter is specified, this function will additionally
|
||||
* check if the query is for exactly one of the post types specified. If a plugin
|
||||
* is causing multiple post types to appear in the query, specifying a post type
|
||||
* will cause this check to return false.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param mixed $post_types Optional. Post type or array of post types
|
||||
* @return bool
|
||||
*/
|
||||
function is_archive() {
|
||||
return (bool) $this->is_archive;
|
||||
function is_archive( $post_types ) {
|
||||
if ( empty( $post_types ) || !$this->is_archive )
|
||||
return (bool) $this->is_archive;
|
||||
|
||||
if ( ! isset( $this->posts[0] ) )
|
||||
return false;
|
||||
|
||||
$post = $this->posts[0];
|
||||
|
||||
return in_array( $post->post_type, (array) $post_types );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3002,7 +3024,7 @@ class WP_Query extends WP_Object_Query {
|
||||
*/
|
||||
function is_singular( $post_types = '' ) {
|
||||
if ( empty( $post_types ) || !$this->is_singular )
|
||||
return $this->is_singular;
|
||||
return (bool) $this->is_singular;
|
||||
|
||||
$post_obj = $this->get_queried_object();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user