実現したいこと
WordPressテーマの中のfunctions.phpの中にcreate_functionが入っています。
PHP8でも対応させたいので、コードの書き換え方を教えてください。
### 発生している問題・分からないこと create_function関数がPHP8.0では削除されているのにも関わらず、functions.phpの中に書き込まれている ### エラーメッセージ ```error Fatal error: Uncaught Error: Call to undefined function create_function() in /home/copainsalon/copain-dog.com/public_html/wp-content/themes/copain/functions.php:116 Stack trace: #0 /home/copainsalon/copain-dog.com/public_html/wp-settings.php(611): include() #1 /home/copainsalon/copain-dog.com/public_html/wp-config.php(96): require_once('/home/copainsal...') #2 /home/copainsalon/copain-dog.com/public_html/wp-load.php(50): require_once('/home/copainsal...') #3 /home/copainsalon/copain-dog.com/public_html/wp-blog-header.php(13): require_once('/home/copainsal...') #4 /home/copainsalon/copain-dog.com/public_html/index.php(17): require('/home/copainsal...') #5 {main} thrown in /home/copainsalon/copain-dog.com/public_html/wp-content/themes/copain/functions.php on line 116
該当のソースコード
/*** シングルページテンプレート ***/ add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
create_functionの書き換えを行えばいいと思うのですが、そのやり方がいまいちよく分かりません。
補足
特になし
調べてヒットした情報などはないのでしょうか?

回答1件
あなたの回答
tips
プレビュー