JQuery行中等高冲突只适用于不注册wp_footer();

时间:2012-03-24 作者:Kharis Blank

我正在尝试制作may自己的Wordpress主题。我希望blogpost丢失DIVs块的场景在行中相等。我正在使用CSS技巧中非常酷的JQuery教程来实现它。这是教程http://css-tricks.com/equal-height-blocks-in-rows/

我正在函数中排队JQuery/JS。php如下:

// Load jQuery 
if ( !is_admin() ) { 
    wp_deregister_script(\'jquery\');
    wp_register_script(\'jquery\',
    ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"),
    false); wp_enqueue_script(\'jquery\'); 
}
// Load Equal Height .js 
function my_equal_height() 
{
    wp_register_script(\'custom_script\', get_template_directory_uri() .
    \'/scripts/equalheight.js\', array(\'jquery\'), \'1.0\' );
    wp_enqueue_script(\'custom_script\'); 
}
add_action(\'wp_enqueue_scripts\', \'my_equal_height\');
但只有当我忽略<?php wp_footer(); ?>. 正如我们所知,不建议省略<?php wp_footer(); ?> 同时开发Wordpress主题。

有人能帮我解决这个问题吗?

任何回应和帮助都将不胜感激。

1 个回复
最合适的回答,由SO网友:David 整理而成

你真的很接近,我认为这些修复应该为你指明正确的方向。我研究并解决了一些语法问题和条件挂钩。希望这能让你朝着正确的方向前进。

// Load \'Working\' jQuery 
add_action( \'init\', \'jquery_register\' );
// register from google and for footer
function jquery_register() {

    if ( is_admin() )
        return;

    wp_deregister_script( \'jquery\' );
    wp_register_script( \'jquery\', \'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\', false, null, true );
    wp_enqueue_script( \'jquery\' );
}

// Try this Equal height: 
function my_equal_height() { 
    wp_enqueue_script( \'equal_height\', get_template_directory_uri().\'/scripts/equalheight.js\', \'jquery\', null, true );
} 
add_action( \'wp_head\', \'my_equal_height\' );
让我知道此解决方案对您的作用:)

结束

相关推荐