Advertisements

is_page_template

Definition:
function is_page_template($template = '') {}

Whether currently in a page template.
This template tag allows you to determine if you are in a page template. You can optionally provide a template name and then the check will be specific to that template.

Parameters

  • string $template: The specific template name if specific matching is required.

Return values

returns:False on failure, true if success.

Source code

function is_page_template($template = '') {

	if (!is_page()) {

		return false;

	}



	global $wp_query;



	$page = $wp_query->get_queried_object();

	$custom_fields = get_post_custom_values('_wp_page_template',$page->ID);

	$page_template = $custom_fields[0];



	// We have no argument passed so just see if a page_template has been specified

	if ( empty( $template ) ) {

		if ( !empty( $page_template ) and ( 'default' != $page_template ) ) {

			return true;

		}

	} elseif ( $template == $page_template) {

		return true;

	}



	return false;

}

2157

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: