|
@@ 166-175 (lines=10) @@
|
| 163 |
|
* @param string|array $post_types Optional. Post type or array of posts types to check against. |
| 164 |
|
* @return bool |
| 165 |
|
*/ |
| 166 |
|
function is_post_type_archive( $post_types = '' ) { |
| 167 |
|
global $wp_query; |
| 168 |
|
|
| 169 |
|
if ( ! isset( $wp_query ) ) { |
| 170 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 171 |
|
return false; |
| 172 |
|
} |
| 173 |
|
|
| 174 |
|
return $wp_query->is_post_type_archive( $post_types ); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
/** |
| 178 |
|
* Is the query for an existing attachment page? |
|
@@ 187-196 (lines=10) @@
|
| 184 |
|
* @param int|string|array|object $attachment Attachment ID, title, slug, or array of such. |
| 185 |
|
* @return bool |
| 186 |
|
*/ |
| 187 |
|
function is_attachment( $attachment = '' ) { |
| 188 |
|
global $wp_query; |
| 189 |
|
|
| 190 |
|
if ( ! isset( $wp_query ) ) { |
| 191 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 192 |
|
return false; |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
return $wp_query->is_attachment( $attachment ); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
/** |
| 199 |
|
* Is the query for an existing author archive page? |
|
@@ 211-220 (lines=10) @@
|
| 208 |
|
* @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames |
| 209 |
|
* @return bool |
| 210 |
|
*/ |
| 211 |
|
function is_author( $author = '' ) { |
| 212 |
|
global $wp_query; |
| 213 |
|
|
| 214 |
|
if ( ! isset( $wp_query ) ) { |
| 215 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 216 |
|
return false; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
return $wp_query->is_author( $author ); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
/** |
| 223 |
|
* Is the query for an existing category archive page? |
|
@@ 235-244 (lines=10) @@
|
| 232 |
|
* @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. |
| 233 |
|
* @return bool |
| 234 |
|
*/ |
| 235 |
|
function is_category( $category = '' ) { |
| 236 |
|
global $wp_query; |
| 237 |
|
|
| 238 |
|
if ( ! isset( $wp_query ) ) { |
| 239 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 240 |
|
return false; |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
return $wp_query->is_category( $category ); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
/** |
| 247 |
|
* Is the query for an existing tag archive page? |
|
@@ 259-268 (lines=10) @@
|
| 256 |
|
* @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. |
| 257 |
|
* @return bool |
| 258 |
|
*/ |
| 259 |
|
function is_tag( $tag = '' ) { |
| 260 |
|
global $wp_query; |
| 261 |
|
|
| 262 |
|
if ( ! isset( $wp_query ) ) { |
| 263 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 264 |
|
return false; |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
return $wp_query->is_tag( $tag ); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
/** |
| 271 |
|
* Is the query for an existing taxonomy archive page? |
|
@@ 288-297 (lines=10) @@
|
| 285 |
|
* @param int|string|array $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. |
| 286 |
|
* @return bool |
| 287 |
|
*/ |
| 288 |
|
function is_tax( $taxonomy = '', $term = '' ) { |
| 289 |
|
global $wp_query; |
| 290 |
|
|
| 291 |
|
if ( ! isset( $wp_query ) ) { |
| 292 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 293 |
|
return false; |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
return $wp_query->is_tax( $taxonomy, $term ); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
/** |
| 300 |
|
* Is the query for an existing date archive? |
|
@@ 349-358 (lines=10) @@
|
| 346 |
|
* @param string|array $feeds Optional feed types to check. |
| 347 |
|
* @return bool |
| 348 |
|
*/ |
| 349 |
|
function is_feed( $feeds = '' ) { |
| 350 |
|
global $wp_query; |
| 351 |
|
|
| 352 |
|
if ( ! isset( $wp_query ) ) { |
| 353 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 354 |
|
return false; |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
return $wp_query->is_feed( $feeds ); |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
/** |
| 361 |
|
* Is the query for a comments feed? |
|
@@ 474-483 (lines=10) @@
|
| 471 |
|
* @param int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty. |
| 472 |
|
* @return bool Whether the query is for an existing single page. |
| 473 |
|
*/ |
| 474 |
|
function is_page( $page = '' ) { |
| 475 |
|
global $wp_query; |
| 476 |
|
|
| 477 |
|
if ( ! isset( $wp_query ) ) { |
| 478 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 479 |
|
return false; |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
return $wp_query->is_page( $page ); |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
/** |
| 486 |
|
* Is the query for paged result and not for the first page? |
|
@@ 583-592 (lines=10) @@
|
| 580 |
|
* @param int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty. |
| 581 |
|
* @return bool Whether the query is for an existing single post. |
| 582 |
|
*/ |
| 583 |
|
function is_single( $post = '' ) { |
| 584 |
|
global $wp_query; |
| 585 |
|
|
| 586 |
|
if ( ! isset( $wp_query ) ) { |
| 587 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 588 |
|
return false; |
| 589 |
|
} |
| 590 |
|
|
| 591 |
|
return $wp_query->is_single( $post ); |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
/** |
| 595 |
|
* Is the query for an existing single post of any post type (post, attachment, page, ... )? |
|
@@ 610-619 (lines=10) @@
|
| 607 |
|
* @param string|array $post_types Optional. Post type or array of post types. Default empty. |
| 608 |
|
* @return bool Whether the query is for an existing single post of any of the given post types. |
| 609 |
|
*/ |
| 610 |
|
function is_singular( $post_types = '' ) { |
| 611 |
|
global $wp_query; |
| 612 |
|
|
| 613 |
|
if ( ! isset( $wp_query ) ) { |
| 614 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); |
| 615 |
|
return false; |
| 616 |
|
} |
| 617 |
|
|
| 618 |
|
return $wp_query->is_singular( $post_types ); |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
/** |
| 622 |
|
* Is the query for a specific time? |