How to get template page URL in WordPress

i want to get template page URL in WordPress and i create a function

function getTplPageURL($TEMPLATE_NAME){
  $url;
 //Code which i need

 $pages = query_posts(array(
     'post_type' =>'page',
     'meta_key'  =>'_wp_page_template',
     'meta_value'=> $TEMPLATE_NAME
 ));
 // cycle through $pages here and either grab the URL
 // from the results or do get_page_link($id) with 
 // the id of the page you want 
 $url = null;
 if(isset($pages[0])) {
     $url = get_page_link($pages[0]['ID']);
 }
 return $url;
}

but when i call this function this error has occurred

Read More

” Fatal error: Cannot use object of type WP_Post as array”

please help me

Related posts

Leave a Reply

3 comments