style.css 在 wordpress 中不起作用

新手上路,请多包涵

我的 Wordpress 有问题,我创建了所有需要的文件,包括 style.css index.php 等,但页面没有样式。在标题中,除其他外,我把这个

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="text/css" href="<?php bloginfo('template_url'); ?>/css/style.css" />

原文由 user3188096 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 758
1 个回答

就我而言,我没有链接 CSS。所以我通过执行以下操作解决了它:

  1. 我创建了一个文件 header.php 这个文件有我的 html 代码,并且在这个文件内部,而不是使用链接手动包含 css 文件,我调用了一个 php 函数 wp_head();这有助于 wordpress 控制我的头部。
     <!DOCTYPE html>
    <html>
      <head>
        <?php wp_head(); ?>
      </head>
      <body>
        <h1>Wordpress</h1>
      </body>
    </html>

之后,我必须在名为 functions.php 的主题文件夹中创建另一个新文件,并使用以下代码在此文件中链接 style.css

 <?php
function files() {
  wp_enqueue_style( 'style', get_stylesheet_uri() );
}
  add_action( 'wp_enqueue_scripts', 'files' );

?>

原文由 Nakityo Anita 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题