首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS JS在wordpress中未更新

CSS JS在wordpress中未更新
EN

Stack Overflow用户
提问于 2021-06-07 23:31:26
回答 1查看 84关注 0票数 0

我正在使用WordPress,并致力于一个儿童主题。我在子主题的assets文件夹中添加了一个custom.css文件。和assets文件夹中的文件夹js,并添加了脚本文件custom_script.js。第一次测试时,我在css中添加了一个警告和一些正文样式。运行良好,但过了一段时间后,我从这些文件中删除了所有内容,但没有更新,也没有添加新内容。请检查一下isses是什么。提前谢谢。网站为https://mealsgroupuk.com/

下面是子主题function.php

代码语言:javascript
复制
<?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

子主题>资产> js > custom_script.js

现在,这两个文件都是空白的,但显示了旧内容。

EN

回答 1

Stack Overflow用户

发布于 2021-06-08 17:12:34

可能是版本(入队)的缓存问题。您可以更改版本,或者每次都使用time()来获取最新版本。

代码语言:javascript
复制
wp_enqueue_script(
   'custom-script',
    get_stylesheet_directory_uri() . '/assets/js/custom_script.js',
    array('jquery'),
    time()
);

不要忘记在生产环境中替换time() (使用主题或插件版本),以获得浏览器和服务器缓存的好处。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67874520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档