【发布时间】:2021-06-07 15:31:26
【问题描述】:
我正在使用 WordPress 并正在开发一个子主题。我在子主题的资产文件夹中添加了一个 custom.css 文件。并在 assets 文件夹中添加了一个文件夹 js,并添加了一个脚本文件 custom_script.js。第一次进行测试时,我在 css 中添加了警报和一些正文样式。运行良好,但一段时间后,我从这些文件中删除了所有内容,但没有更新,也没有添加新内容。请检查是什么问题。提前致谢。网址是https://mealsgroupuk.com/
这里是子主题function.php
<?php
// // Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exi
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( 'iconmoon','bootstrap','bootstrap-theme','chosen','swiper' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 1 );
// END ENQUEUE PARENT ACTION
/* Enqueues the external CSS file */
add_action( 'wp_enqueue_scripts', 'custom_external_styles' );
function custom_external_styles() {
wp_register_style( 'custom-css', get_stylesheet_directory_uri().'/assets/custom.css' );
wp_enqueue_style( 'custom-css' );
}
/* Enqueues the external js file */
function my_scripts_method() {
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri() . '/assets/js/custom_script.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
子主题> 资产 > custom.css
child-theme> assets > js > custom_script.js
现在这两个文件都是空白的,但显示的是旧内容。
【问题讨论】:
-
请检查 codex 以获取 enqueue 样式表和子主题中的 js,您有参数问题
-
感谢 Shakeel、Ahmad 的回复。你能帮我“检查入队样式表和 js 的 codex”吗?我对编码一无所知。
-
请查看此内容,它会对您有所帮助wordpress.stackexchange.com/questions/177157/…
标签: javascript php html css wordpress