【问题标题】:front-page.php not working properly in wordpressfront-page.php 在 wordpress 中无法正常工作
【发布时间】:2013-12-26 08:14:53
【问题描述】:

我是 Web 开发新手,不确定如何解决此问题:

我遇到了一个网站的问题,我目前在我自己的机器上运行在 wordpress 中,并在 header.php 中添加了以下行:

<link rel="stylesheet" type="text/css" href="includes/marquee.css" />
<script type="text/javascript" src="/includes/jquery-1.6.min.js"></script>
<script type="text/javascript" src="/includes/farinspace/jquery.imgpreload.min.js"></script>
<script type="text/javascript" src="/includes/marquee.js"></script>

比我创建的 front-page.php 文件看起来像这样:

<?php get_header(); ?>
<img class="marquee_panel_photo" src="/images/photos/london.jpg" alt="London"   width="100" />
<div class="marquee_container">
        <div class="marquee_photos"></div>
        <div class="marquee_caption">
            <div class="marquee_caption_content"></div>
        </div>
        <div class="marquee_nav"></div>
    </div>

    <div class="marquee_panels">
        <!-- Panel -->
        <div class="marquee_panel">
            <img class="marquee_panel_photo" src="/images/photos/london.jpg" alt="London" width="100" />
            <div class="marquee_panel_caption">
                <img class="marquee_flag" src="/images/template/flag_england.jpg" width="20" height="13" />
                <h2>London</h2>
                <p>Fusce neque dolor adipiscing sed consectetuer et lacinia sit amet quam. Suspendisse wisi quam consectetuer in blandit sed suscipit eu eros.</p>
                <p><a href="#">Check it out!</a></p>
            </div>
        </div>

我的目录结构是这样的: 头版.php 图片/照片 图像/模板 包括

当我在 Firefox 中运行该文件时,我在菜单下方看不到任何内容。没有任何 div 或 javascript 正在运行。当我尝试在 front-page.php 中运行示例 para 时,它会显示出来。

对调试有任何帮助都会很棒

【问题讨论】:

  • 您是否在后端设置了静态首页,并选择使用front-page.php作为您的页面模板?也是wordpress根目录下的front-page.php还是主题目录下的?
  • 是的,我已经在后端将首页设置为静态,现在我正在使用 front-page.php .. front-page.php 在主题根文件夹中

标签: javascript php jquery html wordpress


【解决方案1】:

我看不到解决此问题的答案,因此发布以下代码供其他人参考以解决该问题:

<?php
function my_scripts_method() {
   // register your script location and dependencies
   wp_register_script('custom_script',
       get_template_directory_uri() . '/includes/jquery-1.10.2.min.js', array('jquery')
    );
   // enqueue the script
   wp_enqueue_script('custom_script');


   //add_action('wp_enqueue_scripts', 'my_scripts_method');

   // register your script location and dependencies
   wp_register_script('custom_script1',
       get_template_directory_uri() . '/includes/farinspace/jquery.imgpreload.min.js',
       array('jquery')
    );
   // enqueue the script
   wp_enqueue_script('custom_script1');

  // add_action('wp_enqueue_scripts', 'my_scripts_method');

  // register your script location and dependencies
   wp_register_script('custom_script2',
       get_template_directory_uri() . '/includes/front-page.js',
       array('jquery')
    );
   // enqueue the script
   wp_enqueue_script('custom_script2'); 

   if (is_page_template('our-story.php')) {
       wp_register_script('custom_script3',
       get_template_directory_uri() . '/includes/parallax.js',
       array('jquery')
    );
   // enqueue the script
   wp_enqueue_script('custom_script3'); 

   }

}

   add_action('wp_enqueue_scripts', 'my_scripts_method');


?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 2017-12-18
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    • 2015-06-22
    相关资源
    最近更新 更多