gpt4 book ai didi

css - 在 Wordpress 中添加样式表

转载 作者:太空宇宙 更新时间:2023-11-04 12:22:02 26 4
gpt4 key购买 nike

我是 Wordpress 的新手,我需要将 PSD 转换为 Wordpress 主题。为此,我首先下载了一个裸体 wordpress 主题,并尝试在 function.php 中添加我自己的 css 样式,如下所示:

function naked_scripts()  { 

// get the theme directory style.css and link to it in the header
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style/main.css' );
wp_enqueue_style( 'responsive-style', get_template_directory_uri() . '/style/responsive.css' );
wp_enqueue_style( 'bootstrap-style', get_template_directory_uri() . '/style/bootstrap.min.css' );


// add fitvid
wp_enqueue_script( 'jquery-js', get_template_directory_uri() . '/js/jquery.js', array( 'jquery' ), '1.10.2', true );

// add theme scripts
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.0.3', true );

}
add_action( 'wp_enqueue_scripts', 'naked_scripts' ); // Register this fxn and allow Wordpress to call it automatcally in the header

但在浏览器中我没有得到我的风格,我有他的错误:

 GET http://rota.alwaysdata.net/wp-content/themes/theme1/style/main.css?ver=4.1 

ver=4.1 是什么??

最佳答案

这是 WordPress 添加的缓存破坏程序。您可以使用 wp_enqueue_style

中的 $ver 参数将其设置为任何您想要的数字

http://codex.wordpress.org/Function_Reference/wp_enqueue_style

?ver=X.XX 对样式表的内容没有影响。

CSS 缓存破坏引用:

http://css-tricks.com/snippets/wordpress/prevent-css-caching/ https://www.mojowill.com/developer/get-your-wordpress-css-changes-noticed-immediately/

关于css - 在 Wordpress 中添加样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28296770/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com