【问题标题】:WordPress - images and javascript not workingWordPress - 图像和 javascript 无法正常工作
【发布时间】:2012-07-04 22:47:58
【问题描述】:

我对 WordPress 很陌生。我已将我创建的 HTML 网站 (www.reactmarketing.co.uk/servowatch) 转换为 WordPress。在我的仪表板上,它说主题已安装,但没有显示任何图像并且 JavaScript 无法正常工作。

我的文件夹布局是:wp-content/themese/servowatch
里面的servowatch文件夹是:

footer.php
header.php
images (dir)
index.php
js (dir)
sidebar.php
style.css

我的

里面是这样的。 (从我找到的教程中复制)
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
    /*
     * Print the <title> tag based on what is being viewed.
     */
    global $page, $paged;

    wp_title( '|', true, 'right' );

    // Add the blog name.
    bloginfo( 'name' );

    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) )
        echo " | $site_description";

    // Add a page number if necessary:
    if ( $paged >= 2 || $page >= 2 )
        echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );

    ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/jquery.main.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php
    /* We add some JavaScript to pages with the comment form
     * to support sites with threaded comments (when in use).
     */
    if ( is_singular() && get_option( 'thread_comments' ) )
        wp_enqueue_script( 'comment-reply' );

    /* Always have wp_head() just before the closing </head>
     * tag of your theme, or you will break many plugins, which
     * generally use this hook to add elements to <head> such
     * as styles, scripts, and meta tags.
     */
    wp_head();
?>
</head>

提前致谢,汤姆

【问题讨论】:

    标签: javascript html image wordpress wordpress-theming


    【解决方案1】:

    将模板目录路径添加到您的 java 脚本 src 或图像 src

    <?php bloginfo('template_directory'); ?>/
    
    <script type="text/javascript" src="`<?php bloginfo('template_directory'); ?>/`js/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="`<?php bloginfo('template_directory'); ?>/`js/jquery.main.js"></script>
    

    【讨论】:

      【解决方案2】:

      这是路径问题 :) 将src="js/... 更改为src="&lt;?php bloginfo('template_directory'); ?&gt;/js/... 即可。在 CSS 中,确保将图像指向如下:url('images/image.jpg');

      【讨论】:

      • 所以我认为 JavaScript 现在可以工作了,谢谢。但我仍然无法显示任何图像。在 CSS 中,图像如下所示: .logo{ background:url('/images/logo.png') no-repeat;} 在 HTML 图像中如下所示:
      • 在 CSS 中,不要使用 /images/,只使用 images/。在html中,使用前面提到的&lt;?php bloginfo('template_directory'); ?&gt;/images/...
      猜你喜欢
      • 2012-09-15
      • 2022-12-21
      • 2020-01-14
      • 2017-03-29
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      • 2013-04-17
      • 2015-07-25
      相关资源
      最近更新 更多