【问题标题】:Wordpress – Loading different CSS for different page not workingWordpress – 为不同的页面加载不同的 CSS 不起作用
【发布时间】:2019-08-06 08:46:34
【问题描述】:

我正在使用以下 fork 将不同的 css 样式应用于页面 (ID 130)。

function wipkip_scripts() {
  wp_enqueue_style( 'wipkip-style', get_stylesheet_uri() );

  if ( is_page(130) ) {
    wp_enqueue_style( 'wipkip-style-home', get_stylesheet_uri() . '/style-homepage.css' );
  }
}

问题在于它会生成错误的 URL,我不知道为什么。这是它生成的 URL:

http://myurl.com/wp/wp-content/themes/wipkip/style.css/style-homepage.css?ver=5.2.2

它以某种方式自动在已经存在的 style.css

之后添加 /style-homepage.css

有人知道解决这个问题的方法吗?

干杯

【问题讨论】:

    标签: wordpress wordpress-theming custom-wordpress-pages


    【解决方案1】:

    get_stylesheet_uri() - 获取当前主题样式表的 URI。

    使用get_stylesheet_directory_uri() 检索样式表目录URI,然后附加style-homepage.css。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      • 2021-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多