JavaScript / jQuery не работает на сайте WordPress / PHP - PullRequest
0 голосов
/ 31 июля 2011

Я работаю над сайтом http://www.infinite -possibility.com / , который в настоящее время испытывает проблемы с любым элементом или плагином jQuery, который я добавляю поверх стандартной функциональности JS сайта.

Пример: http://www.infinite -possibility.com / говорящий должен быть слайдером динамического содержимого.

У меня такое ощущение, что это как-то связано с JS / jQueryвызывается несколько раз, но я не могу решить проблему ..

В приложении находится мой файл header.php

Есть идеи?

<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<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" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_directory' ); ?>/css/layout.css" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_directory' ); ?>/css/jScrollPane.css" />

<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="<?php bloginfo( 'stylesheet_directory' ); ?>/css/ie.css"><![endif]-->


<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_enqueue_script("jquery");
    wp_head();

?>
<script type="text/javascript" src="<?php bloginfo( 'stylesheet_directory' ); ?>/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="<?php bloginfo( 'stylesheet_directory' ); ?>/js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php bloginfo( 'stylesheet_directory' ); ?>/js/jScrollPane.js"></script>
<script type="text/javascript">
$(function()
            {
                $('#pane2').jScrollPane({showArrows:true});
            });
</script>
</head>
<body>
<div id="outer_layout">
  <div class="layout">
    <div class="body_container" style="position:relative;">
<a style="position:absolute; left:-54px; top:358px; width:50px; height:50px;" href="<?php echo get_option('home');?>"></a>
      <div class="main">

1 Ответ

1 голос
/ 31 июля 2011

Вам нужно использовать вместо jQuery или $, например:

<script type="text/javascript">
$(function()
            {
                jQuery('#pane2').jScrollPane({showArrows:true});
            });
</script>

Или это тоже может сработать:

jQuery(function ($) {
    /* Your code here using $ */
});

Это потому, что jquery по умолчанию, включенный в wordpress, использует режим noConflict () .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...