WordPress - 图像和JavaScript不起作用

WordPress - images and javascript not working

本文关键字:JavaScript 不起作用 图像 WordPress      更新时间:2023-09-26

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

我的文件夹布局为:wp-content/themese/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>

提前感谢,汤姆

这是

路径问题:)从src="js/...更改为src="<?php bloginfo('template_directory'); ?>/js/...,它将起作用。在 CSS 中,确保像这样指向图像:url('images/image.jpg'); .

将模板目录路径添加到您的 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>