Wordpressサイトの親子関係にある固定ぺージのテンプレート名をアンダーバーで繋ぐ記述ですがエラーが出る様になりました。解決方法を教えて頂きたいです。
もしくは他の記述があれば教えて頂きたいです。
例)page-contact_completeのようにしたい。
fanctions.php
1 add_filter('page_template_hierarchy', 'my_page_templates'); 2 function my_page_templates($templates) { 3 global $wp_query; 4 5 $template = get_page_template_slug(); 6 $pagename = $wp_query->query['pagename']; 7 8 if ($pagename && ! $template) { 9 $pagename = str_replace('/', '_', $pagename); 10 $decoded = urldecode($pagename); 11 12 if ($decoded == $pagename) { 13 array_unshift($templates, "page-{$pagename}.php"); 14 } 15 } 16 17 return $templates; 18 }
回答1件
あなたの回答
tips
プレビュー