第一次将网站制作成 WordPress 主题,我正在观看 2019 年的 YouTube 视频,他们将所有内容都放在兼容设备上,但当我进入主题时,它显示“致命错误:未捕获错误:未定义常量“全部””。是否有其他方法或更好的教程可以提供更多最新信息。
<?php
// adding the css and js files
function cm_setup() {
wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;
0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
wp_enqueue_style('fontawesome', '//kit.fontawesome.com/a8cbd25639.js');
wp_enqueue_style('style', get_stylesheet_uri(), NULL, microtime(), all);
wp_enqueue_script("main", get_theme_file_uri('/js/main.js'), NULL, microtime(), true);
}
add_action('wp_enqueue_scripts', 'cm_setup');
媒体应该是字符串。请参阅文档。
wp_enqueue_style('style', get_stylesheet_uri(), [], '1.0.0', 'all');
[wp_enqueue_style][1] [1]:https://developer.wordpress.org/reference/functions/wp_enqueue_style/