|
@@ 150-159 (lines=10) @@
|
| 147 |
|
* |
| 148 |
|
* @return bool |
| 149 |
|
*/ |
| 150 |
|
function is_archive() { |
| 151 |
|
global $wp_query; |
| 152 |
|
|
| 153 |
|
if ( ! isset( $wp_query ) ) { |
| 154 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 155 |
|
return false; |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
return $wp_query->is_archive(); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
/** |
| 162 |
|
* Is the query for an existing post type archive page? |
|
@@ 171-180 (lines=10) @@
|
| 168 |
|
* @param string|array $post_types Optional. Post type or array of posts types to check against. |
| 169 |
|
* @return bool |
| 170 |
|
*/ |
| 171 |
|
function is_post_type_archive( $post_types = '' ) { |
| 172 |
|
global $wp_query; |
| 173 |
|
|
| 174 |
|
if ( ! isset( $wp_query ) ) { |
| 175 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 176 |
|
return false; |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
return $wp_query->is_post_type_archive( $post_types ); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
/** |
| 183 |
|
* Is the query for an existing attachment page? |
|
@@ 192-201 (lines=10) @@
|
| 189 |
|
* @param int|string|array|object $attachment Attachment ID, title, slug, or array of such. |
| 190 |
|
* @return bool |
| 191 |
|
*/ |
| 192 |
|
function is_attachment( $attachment = '' ) { |
| 193 |
|
global $wp_query; |
| 194 |
|
|
| 195 |
|
if ( ! isset( $wp_query ) ) { |
| 196 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 197 |
|
return false; |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
return $wp_query->is_attachment( $attachment ); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
/** |
| 204 |
|
* Is the query for an existing author archive page? |
|
@@ 216-225 (lines=10) @@
|
| 213 |
|
* @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames |
| 214 |
|
* @return bool |
| 215 |
|
*/ |
| 216 |
|
function is_author( $author = '' ) { |
| 217 |
|
global $wp_query; |
| 218 |
|
|
| 219 |
|
if ( ! isset( $wp_query ) ) { |
| 220 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 221 |
|
return false; |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
return $wp_query->is_author( $author ); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
/** |
| 228 |
|
* Is the query for an existing category archive page? |
|
@@ 240-249 (lines=10) @@
|
| 237 |
|
* @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. |
| 238 |
|
* @return bool |
| 239 |
|
*/ |
| 240 |
|
function is_category( $category = '' ) { |
| 241 |
|
global $wp_query; |
| 242 |
|
|
| 243 |
|
if ( ! isset( $wp_query ) ) { |
| 244 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 245 |
|
return false; |
| 246 |
|
} |
| 247 |
|
|
| 248 |
|
return $wp_query->is_category( $category ); |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
/** |
| 252 |
|
* Is the query for an existing tag archive page? |
|
@@ 264-273 (lines=10) @@
|
| 261 |
|
* @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. |
| 262 |
|
* @return bool |
| 263 |
|
*/ |
| 264 |
|
function is_tag( $tag = '' ) { |
| 265 |
|
global $wp_query; |
| 266 |
|
|
| 267 |
|
if ( ! isset( $wp_query ) ) { |
| 268 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 269 |
|
return false; |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
return $wp_query->is_tag( $tag ); |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
/** |
| 276 |
|
* Is the query for an existing custom taxonomy archive page? |
|
@@ 293-302 (lines=10) @@
|
| 290 |
|
* @param int|string|array $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. |
| 291 |
|
* @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives). |
| 292 |
|
*/ |
| 293 |
|
function is_tax( $taxonomy = '', $term = '' ) { |
| 294 |
|
global $wp_query; |
| 295 |
|
|
| 296 |
|
if ( ! isset( $wp_query ) ) { |
| 297 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 298 |
|
return false; |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
return $wp_query->is_tax( $taxonomy, $term ); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
/** |
| 305 |
|
* Is the query for an existing date archive? |
|
@@ 313-322 (lines=10) @@
|
| 310 |
|
* |
| 311 |
|
* @return bool |
| 312 |
|
*/ |
| 313 |
|
function is_date() { |
| 314 |
|
global $wp_query; |
| 315 |
|
|
| 316 |
|
if ( ! isset( $wp_query ) ) { |
| 317 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 318 |
|
return false; |
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
return $wp_query->is_date(); |
| 322 |
|
} |
| 323 |
|
|
| 324 |
|
/** |
| 325 |
|
* Is the query for an existing day archive? |
|
@@ 333-342 (lines=10) @@
|
| 330 |
|
* |
| 331 |
|
* @return bool |
| 332 |
|
*/ |
| 333 |
|
function is_day() { |
| 334 |
|
global $wp_query; |
| 335 |
|
|
| 336 |
|
if ( ! isset( $wp_query ) ) { |
| 337 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 338 |
|
return false; |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
return $wp_query->is_day(); |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
/** |
| 345 |
|
* Is the query for a feed? |
|
@@ 354-363 (lines=10) @@
|
| 351 |
|
* @param string|array $feeds Optional feed types to check. |
| 352 |
|
* @return bool |
| 353 |
|
*/ |
| 354 |
|
function is_feed( $feeds = '' ) { |
| 355 |
|
global $wp_query; |
| 356 |
|
|
| 357 |
|
if ( ! isset( $wp_query ) ) { |
| 358 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 359 |
|
return false; |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
return $wp_query->is_feed( $feeds ); |
| 363 |
|
} |
| 364 |
|
|
| 365 |
|
/** |
| 366 |
|
* Is the query for a comments feed? |
|
@@ 374-383 (lines=10) @@
|
| 371 |
|
* |
| 372 |
|
* @return bool |
| 373 |
|
*/ |
| 374 |
|
function is_comment_feed() { |
| 375 |
|
global $wp_query; |
| 376 |
|
|
| 377 |
|
if ( ! isset( $wp_query ) ) { |
| 378 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 379 |
|
return false; |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
return $wp_query->is_comment_feed(); |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
/** |
| 386 |
|
* Is the query for the front page of the site? |
|
@@ 403-412 (lines=10) @@
|
| 400 |
|
* |
| 401 |
|
* @return bool True, if front of site. |
| 402 |
|
*/ |
| 403 |
|
function is_front_page() { |
| 404 |
|
global $wp_query; |
| 405 |
|
|
| 406 |
|
if ( ! isset( $wp_query ) ) { |
| 407 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 408 |
|
return false; |
| 409 |
|
} |
| 410 |
|
|
| 411 |
|
return $wp_query->is_front_page(); |
| 412 |
|
} |
| 413 |
|
|
| 414 |
|
/** |
| 415 |
|
* Determines if the query is for the blog homepage. |
|
@@ 432-441 (lines=10) @@
|
| 429 |
|
* |
| 430 |
|
* @return bool True if blog view homepage, otherwise false. |
| 431 |
|
*/ |
| 432 |
|
function is_home() { |
| 433 |
|
global $wp_query; |
| 434 |
|
|
| 435 |
|
if ( ! isset( $wp_query ) ) { |
| 436 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 437 |
|
return false; |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
return $wp_query->is_home(); |
| 441 |
|
} |
| 442 |
|
|
| 443 |
|
/** |
| 444 |
|
* Is the query for an existing month archive? |
|
@@ 452-461 (lines=10) @@
|
| 449 |
|
* |
| 450 |
|
* @return bool |
| 451 |
|
*/ |
| 452 |
|
function is_month() { |
| 453 |
|
global $wp_query; |
| 454 |
|
|
| 455 |
|
if ( ! isset( $wp_query ) ) { |
| 456 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 457 |
|
return false; |
| 458 |
|
} |
| 459 |
|
|
| 460 |
|
return $wp_query->is_month(); |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
/** |
| 464 |
|
* Is the query for an existing single page? |
|
@@ 479-488 (lines=10) @@
|
| 476 |
|
* @param int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty. |
| 477 |
|
* @return bool Whether the query is for an existing single page. |
| 478 |
|
*/ |
| 479 |
|
function is_page( $page = '' ) { |
| 480 |
|
global $wp_query; |
| 481 |
|
|
| 482 |
|
if ( ! isset( $wp_query ) ) { |
| 483 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 484 |
|
return false; |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
return $wp_query->is_page( $page ); |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
/** |
| 491 |
|
* Is the query for paged result and not for the first page? |
|
@@ 499-508 (lines=10) @@
|
| 496 |
|
* |
| 497 |
|
* @return bool |
| 498 |
|
*/ |
| 499 |
|
function is_paged() { |
| 500 |
|
global $wp_query; |
| 501 |
|
|
| 502 |
|
if ( ! isset( $wp_query ) ) { |
| 503 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 504 |
|
return false; |
| 505 |
|
} |
| 506 |
|
|
| 507 |
|
return $wp_query->is_paged(); |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
/** |
| 511 |
|
* Is the query for a post or page preview? |
|
@@ 519-528 (lines=10) @@
|
| 516 |
|
* |
| 517 |
|
* @return bool |
| 518 |
|
*/ |
| 519 |
|
function is_preview() { |
| 520 |
|
global $wp_query; |
| 521 |
|
|
| 522 |
|
if ( ! isset( $wp_query ) ) { |
| 523 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 524 |
|
return false; |
| 525 |
|
} |
| 526 |
|
|
| 527 |
|
return $wp_query->is_preview(); |
| 528 |
|
} |
| 529 |
|
|
| 530 |
|
/** |
| 531 |
|
* Is the query for the robots file? |
|
@@ 539-548 (lines=10) @@
|
| 536 |
|
* |
| 537 |
|
* @return bool |
| 538 |
|
*/ |
| 539 |
|
function is_robots() { |
| 540 |
|
global $wp_query; |
| 541 |
|
|
| 542 |
|
if ( ! isset( $wp_query ) ) { |
| 543 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 544 |
|
return false; |
| 545 |
|
} |
| 546 |
|
|
| 547 |
|
return $wp_query->is_robots(); |
| 548 |
|
} |
| 549 |
|
|
| 550 |
|
/** |
| 551 |
|
* Is the query for a search? |
|
@@ 559-568 (lines=10) @@
|
| 556 |
|
* |
| 557 |
|
* @return bool |
| 558 |
|
*/ |
| 559 |
|
function is_search() { |
| 560 |
|
global $wp_query; |
| 561 |
|
|
| 562 |
|
if ( ! isset( $wp_query ) ) { |
| 563 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 564 |
|
return false; |
| 565 |
|
} |
| 566 |
|
|
| 567 |
|
return $wp_query->is_search(); |
| 568 |
|
} |
| 569 |
|
|
| 570 |
|
/** |
| 571 |
|
* Is the query for an existing single post? |
|
@@ 588-597 (lines=10) @@
|
| 585 |
|
* @param int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty. |
| 586 |
|
* @return bool Whether the query is for an existing single post. |
| 587 |
|
*/ |
| 588 |
|
function is_single( $post = '' ) { |
| 589 |
|
global $wp_query; |
| 590 |
|
|
| 591 |
|
if ( ! isset( $wp_query ) ) { |
| 592 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 593 |
|
return false; |
| 594 |
|
} |
| 595 |
|
|
| 596 |
|
return $wp_query->is_single( $post ); |
| 597 |
|
} |
| 598 |
|
|
| 599 |
|
/** |
| 600 |
|
* Is the query for an existing single post of any post type (post, attachment, page, |
|
@@ 616-625 (lines=10) @@
|
| 613 |
|
* @param string|array $post_types Optional. Post type or array of post types. Default empty. |
| 614 |
|
* @return bool Whether the query is for an existing single post of any of the given post types. |
| 615 |
|
*/ |
| 616 |
|
function is_singular( $post_types = '' ) { |
| 617 |
|
global $wp_query; |
| 618 |
|
|
| 619 |
|
if ( ! isset( $wp_query ) ) { |
| 620 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 621 |
|
return false; |
| 622 |
|
} |
| 623 |
|
|
| 624 |
|
return $wp_query->is_singular( $post_types ); |
| 625 |
|
} |
| 626 |
|
|
| 627 |
|
/** |
| 628 |
|
* Is the query for a specific time? |
|
@@ 636-645 (lines=10) @@
|
| 633 |
|
* |
| 634 |
|
* @return bool |
| 635 |
|
*/ |
| 636 |
|
function is_time() { |
| 637 |
|
global $wp_query; |
| 638 |
|
|
| 639 |
|
if ( ! isset( $wp_query ) ) { |
| 640 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 641 |
|
return false; |
| 642 |
|
} |
| 643 |
|
|
| 644 |
|
return $wp_query->is_time(); |
| 645 |
|
} |
| 646 |
|
|
| 647 |
|
/** |
| 648 |
|
* Is the query for a trackback endpoint call? |
|
@@ 656-665 (lines=10) @@
|
| 653 |
|
* |
| 654 |
|
* @return bool |
| 655 |
|
*/ |
| 656 |
|
function is_trackback() { |
| 657 |
|
global $wp_query; |
| 658 |
|
|
| 659 |
|
if ( ! isset( $wp_query ) ) { |
| 660 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 661 |
|
return false; |
| 662 |
|
} |
| 663 |
|
|
| 664 |
|
return $wp_query->is_trackback(); |
| 665 |
|
} |
| 666 |
|
|
| 667 |
|
/** |
| 668 |
|
* Is the query for an existing year archive? |
|
@@ 676-685 (lines=10) @@
|
| 673 |
|
* |
| 674 |
|
* @return bool |
| 675 |
|
*/ |
| 676 |
|
function is_year() { |
| 677 |
|
global $wp_query; |
| 678 |
|
|
| 679 |
|
if ( ! isset( $wp_query ) ) { |
| 680 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 681 |
|
return false; |
| 682 |
|
} |
| 683 |
|
|
| 684 |
|
return $wp_query->is_year(); |
| 685 |
|
} |
| 686 |
|
|
| 687 |
|
/** |
| 688 |
|
* Is the query a 404 (returns no results)? |
|
@@ 696-705 (lines=10) @@
|
| 693 |
|
* |
| 694 |
|
* @return bool |
| 695 |
|
*/ |
| 696 |
|
function is_404() { |
| 697 |
|
global $wp_query; |
| 698 |
|
|
| 699 |
|
if ( ! isset( $wp_query ) ) { |
| 700 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 701 |
|
return false; |
| 702 |
|
} |
| 703 |
|
|
| 704 |
|
return $wp_query->is_404(); |
| 705 |
|
} |
| 706 |
|
|
| 707 |
|
/** |
| 708 |
|
* Is the query for an embedded post? |
|
@@ 716-725 (lines=10) @@
|
| 713 |
|
* |
| 714 |
|
* @return bool Whether we're in an embedded post or not. |
| 715 |
|
*/ |
| 716 |
|
function is_embed() { |
| 717 |
|
global $wp_query; |
| 718 |
|
|
| 719 |
|
if ( ! isset( $wp_query ) ) { |
| 720 |
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
| 721 |
|
return false; |
| 722 |
|
} |
| 723 |
|
|
| 724 |
|
return $wp_query->is_embed(); |
| 725 |
|
} |
| 726 |
|
|
| 727 |
|
/** |
| 728 |
|
* Is the query the main query? |