WordPress功能PHP问题

时间:2014-05-08 18:08:27

标签: php wordpress

我不知道自己做错了什么。当我使用以下代码时,实际上没有任何内容链接到页面,除了底部的随机文本:

<?php

    function salt_scripts() {
        //global $wp_styles;
        //wp_enqueue_style( 'stylesheet', 'netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
        //wp_enqueue_style( 'stylesheet', 'http://fonts.googleapis.com/css?family=Varela');


        // Loads main stylesheet
        wp_enqueue_style( 'style', get_stylesheet_uri() );
        wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
        wp_enqueue_style( 'bootstrap-theme', get_template_directory_uri() . '/css/bootstrap-theme.min.css' );
        wp_enqueue_style( 'custom-styles', get_template_directory_uri() . '/css/custom-styles.css' );
    }

    add_action( 'wp_enqueue_scripts', 'salt_scripts' );

?>


LKDJFLSDKJFLSDKFJSLDKFJ WORK

我真的不知道还有什么可尝试的。我去过几十个网站,并从默认的WordPress主题中窃取了代码位。

我的文件夹结构如下:

salt
    css
        bootstrap.css
        bootstrap-theme.min.css
        custom-styles.css
    img
    js

    style.css
    header.php
    index.php
    functions.php

这就是我的header.php中的内容:

<body data-spy="scroll" data-target="#main-nav" data-offset="120">

<!-- Begin Main Nav-->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation" id="main-nav">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="fa fa-bars"></span>
      </button>
      <a class="navbar-brand" href="#home"><img src="images/SaltSolutionsLogo.jpg" alt="SALT Solutions" /></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        <li><a href="#about" onclick="ga('send', 'event', 'Main Navigation', 'click', 'About Us');">About</a></li>
        <li><a href="#solutions" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Solutions');">Solutions</a></li>
        <li><a href="#casestudies" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Case Studies');">Case Studies</a></li>
        <li><a href="#resources" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Resources');">Resources</a></li>
        <li><a href="#calculate" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Calculate');">Calculate</a></li>
        <li><a href="#ourteam" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Our Team');">Our Team</a></li>
        <li><a href="#blog" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Blog');">Blog</a></li>
        <li><a href="#contact" onclick="ga('send', 'event', 'Main Navigation', 'click', 'Contact');">Contact</a></li>
      </ul>

      <ul class="nav navbar-nav navbar-right social-media hidden">
        <li><a href="#" target="_blank" onclick="ga('send', 'event', 'Social Media', 'click', 'Facebook');"><img src="images/facebook.png" alt="Facebook" /></a></li>
        <li><a href="#" target="_blank" onclick="ga('send', 'event', 'Social Media', 'click', 'Twitter');"><img src="images/twitter.png" alt="Twitter" /></a></li>
        <li><a href="#" target="_blank" onclick="ga('send', 'event', 'Social Media', 'click', 'GooglePLus');"><img src="images/googleplus.png" alt="Google+" /></a></li>
        <li><a href="#" target="_blank" onclick="ga('send', 'event', 'Social Media', 'click', 'LinkedIn');"><img src="images/linkedin.png" alt="LinkedIn" /></a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<!--End main-nav --> 

1 个答案:

答案 0 :(得分:0)

你错过了文档的顶部,这就是为什么这不起作用。

将以下内容添加到header.php的顶部:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <title><?php wp_title(); ?></title>
    <?php wp_head(); ?>
</head>

还有更多可以/应该去的地方,但这会让你开始并解决你的CSS加载问题。

关闭footer.php

中的HTML标记

</body>之前footer.php添加<?php wp_footer(); ?>

E.g。

    <?php wp_footer(); ?>
</body>
</html>