如何去除wordpress主题css后面的的版本号

版本号会带来缓冲,怎么修改css都没有用。因此,二次开发必须把css后面的版本号去除。

方法:

在functions.php文件中找到:

wp_enqueue_style()函数,例如,我找到的是如下:

wp_enqueue_style( 'oceanedge-style', get_stylesheet_uri(), array(), _oceanedge_VERSION );
wp_style_add_data( 'oceanedge-style', 'rtl', 'replace' );
wp_enqueue_style( 'oceanedge-theme-bt-style', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), _oceanedge_VERSION );
wp_enqueue_style( 'oceanedge-theme-style', get_template_directory_uri() . '/assets/css/theme-style.css', array(), _oceanedge_VERSION );
wp_enqueue_style( 'oceanedge-theme-responsive', get_template_directory_uri() . '/assets/css/responsive.css', array(), _oceanedge_VERSION );

把第一句最后面的参数 _oceanedge_VERSION 改成 null 即可。

wp_enqueue_style( 'oceanedge-style', get_stylesheet_uri(), array(), null );
wp_style_add_data( 'oceanedge-style', 'rtl', 'replace' );
wp_enqueue_style( 'oceanedge-theme-bt-style', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), _oceanedge_VERSION );
wp_enqueue_style( 'oceanedge-theme-style', get_template_directory_uri() . '/assets/css/theme-style.css', array(), _oceanedge_VERSION );
wp_enqueue_style( 'oceanedge-theme-responsive', get_template_directory_uri() . '/assets/css/responsive.css', array(), _oceanedge_VERSION );

需要修改哪一个就把最后一个参数改为null。