你可能在找
1-get_permalink( get_page_by_path( \'slug\' ) )
2-get_permalink( get_page_by_title( \'slug\' ) )
3-home_url( \'/slug/\' )
作用get_page_by_path 和get_page_by_title 返回Post Object.
References: 
- get_page_by_path
get_page_by_path( string $page_path, string $output = OBJECT, string|array $post_type = \'page\' )
- get_page_by_title
get_page_by_title( string $page_title, string $output = OBJECT, string|array $post_type = \'page\' )
Update
您可以从所选模板获取页面/帖子。
$pages = get_pages(array(
    \'meta_key\' => \'_wp_page_template\',
    \'meta_value\' => \'custom-template.php\'
));
foreach($pages as $page){
    echo $page->ID.\'<br />\';
}
 上面的代码返回具有自定义模板的页面的post对象数组。已选择php模板。
如果您只是想返回页面ID,那么您可以尝试get_posts 作用
$args = array(
    \'post_type\' => \'page\',
    \'fields\' => \'ids\',
    \'nopaging\' => true,
    \'meta_key\' => \'_wp_page_template\',
    \'meta_value\' => \'page-special.php\'
);
$pages = get_posts( $args );
foreach ( $pages as $page ) 
   echo $page . \'</br>\';
Reference: Get page id by template