怪人 大佬有话说 :
求助 PHP7.3报错。要怎样修改呢?
/**
* 不同分类使用不同的文章模板
* From https://www.大学.com/custom-single-post-template.html
*/
//定义模板文件所在目录为 single 文件夹
define(SINGLE_PATH, TEMPLATEPATH . ‘/single’);
//自动选择模板的函数
function wpdaxue_single_template($single) {
global $wp_query, $post;
//通过分类别名或ID选择模板文件
foreach((array)get_the_category() as $cat) :
if(file_exists(SINGLE_PATH . ‘/single-cat-‘ . $cat->slug . ‘.php’)) {
return SINGLE_PATH . ‘/single-cat-‘ . $cat->slug . ‘.php’;
}elseif(file_exists(SINGLE_PATH . ‘/single-cat-‘ . $cat->term_id . ‘.php’)){
return SINGLE_PATH . ‘/single-cat-‘ . $cat->term_id . ‘.php’;
}elseif(file_exists(SINGLE_PATH . ‘/single.php’)){
return SINGLE_PATH . ‘/single.php’;
}
endforeach;
}
//通过 single_template 钩子挂载函数
add_filter(‘single_template’, ‘wpdaxue_single_template’);
错误行:define(SINGLE_PATH, TEMPLATEPATH . ‘/single’);
报错信息:Warning: Use of undefined constant SINGLE_PATH – assumed ‘SINGLE_PATH’ (this will throw an Error in a future version of PHP) in /www/wwwroot/省略
要怎样修改呢大佬
一个不知名网友 大佬有话说 :
这个问题你就只能自己弄了
小混混 大佬有话说 :
常量加双引号就可以了
参考:https://www.70ol.com/235.html