2016-04-29 5 views
0

I持って次のカスタムページテンプレートファイル名:Modify関数

  • テンプレートについて-1.php
  • テンプレートについて-2.php
  • テンプレート家庭1.php
  • テンプレート家庭2.php

私はページテンプレートを取得するには、この機能を持っている:

function get_page_templates_select() { 
$teh_cats = get_page_templates(); 
foreach ($teh_cats as $template_name => $template_filename) { 
    $results[] = $template_name; 
    } 
    return $results; 
} 

ファイル名に "home"が含まれているテンプレートのみを返すように関数を変更するにはどうすればよいですか?

答えて

1

は...

if (stripos(strtolower($template_filename), 'home') !== false) { 
    $results[] = $template_name; 
} 
+0

良い仕事を....... – Fil

0

を通してそれを考えた後、私はあなたが使用することができますねそれを考え出した:

function get_page_templates_select() { 
$teh_cats = get_page_templates(); 
foreach ($teh_cats as $template_name => $template_filename) { 
    if (preg_match('/home/i', $template_filename)) { 
     $results[] = $template_name; 
    } 
    } 
    return $results; 
} 
関連する問題