| | 495 | /** |
|---|
| | 496 | * is_page_template() - Determine wether or not we are in a page template |
|---|
| | 497 | * |
|---|
| | 498 | * This template tag allows you to determine wether or not you are in a page template. |
|---|
| | 499 | * You can optional provide a template name and then the check will be specific to |
|---|
| | 500 | * that template. |
|---|
| | 501 | * |
|---|
| | 502 | * @package Template Tags |
|---|
| | 503 | * @global object $wp_query |
|---|
| | 504 | * @param string $template The specific template name if specific matching is required |
|---|
| | 505 | */ |
|---|
| | 506 | function is_page_template($template = '') { |
|---|
| | 507 | if (!is_page()) { |
|---|
| | 508 | return false; |
|---|
| | 509 | } |
|---|
| | 510 | |
|---|
| | 511 | global $wp_query; |
|---|
| | 512 | |
|---|
| | 513 | $page = $wp_query->get_queried_object(); |
|---|
| | 514 | $custom_fields = get_post_custom_values('_wp_page_template',$page->ID); |
|---|
| | 515 | $page_template = $custom_fields[0]; |
|---|
| | 516 | |
|---|
| | 517 | // We have no argument passed so just see if a page_template has been specified |
|---|
| | 518 | if ( empty( $template ) ) { |
|---|
| | 519 | if (!empty( $page_template ) ) { |
|---|
| | 520 | return true; |
|---|
| | 521 | } |
|---|
| | 522 | } elseif ( $template == $page_template) { |
|---|
| | 523 | return true; |
|---|
| | 524 | } |
|---|
| | 525 | |
|---|
| | 526 | return false; |
|---|
| | 527 | } |
|---|
| | 528 | |
|---|