<pre class="lang:php decode:true ">/**
 * Returns a post object based on the template slug
 * 
 * @param $template_slug the filename of the template
 * @return Post object of the first page found, else false
 */
function ic_get_page_by_template( $template_slug, $args = array() ) {
	$defaults = array(
		'post_type' =&gt; 'page',
		'posts_per_page' =&gt; '1',
		'meta_query' =&gt; array (
			array(
				'key' 	=&gt; '_wp_page_template',
				'value' =&gt; $template_slug
				),
			)
		);

	$args = wp_parse_args( $args, $defaults );;

	$pages = get_posts( $args );
	if ( $pages ) {
		return $pages[0];
	}
	return false;
}</pre>
&nbsp;