实时链接中的jquery和样式

实时链接中的jquery和样式,jquery,ajax,wordpress,Jquery,Ajax,Wordpress,我在尝试使用WordPress和live链接时遇到了一些问题 让我解释一下: 我在类别中有此链接,名为: <a href="p?32" id="control">event 32</a> single.php中的jquery是: function the_gallery() { $attachments = attachments_get_attachments(); $total_attachments = count($attachments);

我在尝试使用WordPress和live链接时遇到了一些问题

让我解释一下:

我在类别中有此链接,名为:

<a href="p?32" id="control">event 32</a>
single.php中的jquery是:

function the_gallery() {

    $attachments = attachments_get_attachments();
    $total_attachments = count($attachments);

    if( $total_attachments > 0 )
    {
        for ($i=0; $i < $total_attachments; $i++)

        {
            $url =  wp_get_attachment_image( $attachments[$i]['id'],
                'bullet-event');
            $lrgurl = wp_get_attachment_image_src( $attachments[$i]['id'], 'large' );




            echo '

            <a href="'.$lrgurl[0].'"
            rel="#overlay" title="'.$attachments[$i]['title'].'">
            ' . $url . '
            </a> ';


        }
    }

}
var wrapEveryN=函数(n,元素,包装器){
对于(变量i=0;i
问题来了,在单曲里面我必须管理一个图像库(循环)一个fancybox和样式。。。唯一正确显示的是样式,但我不知道js为什么不工作:


我的所有代码和插件都位于
plugins.php
&
main.php

我假设您的js代码位于就绪块中,因此不会执行2次

请尝试以下示例:

var wrapEveryN = function(n, elements, wrapper) {
    for (var i=0; i< elements.length; i+=n) {
        elements.slice(i,i+n).wrapAll(wrapper);
    }
}

wrapEveryN( 12, $("#slideShow a"), '<div></div>' );

$('#slideShow').cycle({
    fx:     'scrollLeft'
});
$('theEvent').load(post#u id,function(){
wrapEveryN(12,$(“幻灯片a”),”;
$(“#幻灯片放映”)。循环({
fx:‘向左滚动’;
});
});
PS:您应该只加载

显示您的js代码(用于gallery)
function the_gallery() {

    $attachments = attachments_get_attachments();
    $total_attachments = count($attachments);

    if( $total_attachments > 0 )
    {
        for ($i=0; $i < $total_attachments; $i++)

        {
            $url =  wp_get_attachment_image( $attachments[$i]['id'],
                'bullet-event');
            $lrgurl = wp_get_attachment_image_src( $attachments[$i]['id'], 'large' );




            echo '

            <a href="'.$lrgurl[0].'"
            rel="#overlay" title="'.$attachments[$i]['title'].'">
            ' . $url . '
            </a> ';


        }
    }

}
var wrapEveryN = function(n, elements, wrapper) {
    for (var i=0; i< elements.length; i+=n) {
        elements.slice(i,i+n).wrapAll(wrapper);
    }
}

wrapEveryN( 12, $("#slideShow a"), '<div></div>' );

$('#slideShow').cycle({
    fx:     'scrollLeft'
});
$('#theEvent').load(post_id, function(){
  wrapEveryN( 12, $("#slideShow a"), '<div></div>' );

  $('#slideShow').cycle({
    fx: 'scrollLeft';
  });
});