worepressのエラー 「Warning: Use of undefined constant *** – assumed ‘***’ (this will throw an Error in a future version of PHP) in…」

php7,2以降ではpageやカテゴリー名をクオートで囲まないとエラーになる

php7.4にヴァージンアップすると、

Warning: Use of undefined constant page – assumed ‘page’ (this will throw an Error in a future version of PHP) in…/single.php on line…

というエラーが出て、sidebarが表示されない。

該当する行の

<?php get_sidebar(page)>を

<?php get_sidebar(page)>

とクオートで囲んで解決

 

参考にしたサイト

【WordPressエラー対処法】Warning: Use of undefined constant *** – assumed ‘***’ (this will throw an Error in a future version of PHP) in…

Warning: Use of undefined constant XXXXX – assumed ‘XXXXX’ (this will throw an Error in a future version of PHP) in ~というエラーが出た場合の対処方法

PHP7.2では、クオートしない文字列は、その名前のグローバル定数が定義されていない場合は単なる文字列という扱いになる。