我的子主题的jscroll窗格问题

时间:2012-08-13 作者:Rasha Nour Eldin

我正在尝试使用jscrollpane,但我尝试了所有方法,它仍然不起作用

这是我的功能页

<?php
/**
 * Custom Child Theme Functions
 *
 * This file\'s parent directory can be moved to the wp-content/themes directory 
 * to allow this Child theme to be activated in the Appearance - Themes section of the WP-Admin.
 *
 * Included are a set of constants that can be defined to customize aspects of Thematic\'s 
 * functionality, as well as a sample function that will add a home link to your menu.
 * "Uncomment" or add more to cusomize the functionality of your Child Theme.
 *
 * More ideas can be found in the community documentation for Thematic
 * @link http://docs.thematictheme.com
 *
 * @package ThematicSampleChildTheme
 * @subpackage ThemeInit
 */


// Unleash the power of Thematic\'s dynamic classes
// 
// define(\'THEMATIC_COMPATIBLE_BODY_CLASS\', true);
// define(\'THEMATIC_COMPATIBLE_POST_CLASS\', true);

// Unleash the power of Thematic\'s comment form
//
// define(\'THEMATIC_COMPATIBLE_COMMENT_FORM\', true);

// Unleash the power of Thematic\'s feed link functions
//

// define(\'THEMATIC_COMPATIBLE_FEEDLINKS\', true);


// Adds a home link to your menu
// http://codex.wordpress.org/Template_Tags/wp_page_menu
//function childtheme_menu_args($args) {
//    $args = array(
//        \'show_home\' => \'Home\',
//        \'sort_column\' => \'menu_order\',
//        \'menu_class\' => \'menu\',
//        \'echo\' => false
//    );
//  return $args;
//}
//add_filter(\'wp_page_menu_args\',\'childtheme_menu_args\');
?>
<?php
include("custompost_functions.php");
/* ********************************************** */
/* Remove the standard Thematic menu */
/* ********************************************** */
function remove_menu() {
remove_action(\'thematic_header\',\'thematic_access\',9);
}
add_action(\'init\', \'remove_menu\');
// Moving the thematic menu above the header
add_action(\'thematic_header\',\'thematic_access\',6);


/* ********************************************** */
/* Register Menu */
/* ********************************************** */
function register_my_menus() {
    register_nav_menus(
        array(
            \'primary-menu\' => __( \'Primary Menu\' ),
            \'footer-menu\' => __( \'Footer Menu\' ),
            \'side-menu\' => __( \'Side Menu\' ),

        )
    );
}
add_action( \'init\', \'register_my_menus\' );
/* ********************************************** */
/* Footer Menu */
/* ********************************************** */
function footer_menu() {

   if ( has_nav_menu( \'footer-menu\' ) ) {
    wp_nav_menu( array( \'theme_location\' => \'footer-menu\',
                \'container_class\'=>\'footer-menu\',
                \'menu_class\' => \'sf-menu\', // we assign the sf-menu class to the menu ul so that superfish works on this menu too
                ) );

    }
}

add_action(\'thematic_footer\',\'footer_menu\',41);
function side_menu() {

   if ( has_nav_menu( \'side-menu\' ) ) {
    wp_nav_menu( array( \'theme_location\' => \'side-menu\',
                \'container_class\'=>\'side-menu\',
                \'menu_class\' => \'side-menu\', // we assign the sf-menu class to the menu ul so that superfish works on this menu too
                ) );

    }
}

add_action(\'thematic_abovemainasides\',\'side-menu\');
/* ********************************************** */
/* Footer Social Menu */
/* ********************************************** */
function social_menu(){ ?>
<div class="social">
<ul class="sf-menu">
<li><a href="#">Follow Us</a></li>
<li><a href="#"><img src="<?php bloginfo(\'stylesheet_directory\'); ?>/images/Facebook.png" width="16" height="16" /></a></li>
<li><a href="#"><img src="<?php bloginfo(\'stylesheet_directory\'); ?>/images/Twitter.png" width="16" height="16" /></a></li>
<li><a href="#"><img src="<?php bloginfo(\'stylesheet_directory\'); ?>/images/Skype.png" width="16" height="16" /></a></li>
</ul>
</div>
<?php }
add_action(\'thematic_footer\',\'social_menu\',44);
?>
<?php
/* ********************************************** */
/* Intro Message */
/* ********************************************** */
if(!function_exists(\'getPageContent\'))
{
function getPageContent($pageId,$max_char)
{
if(!is_numeric($pageId))
{
return;
}
global $wpdb;
$nsquery = \'SELECT DISTINCT * FROM \' . $wpdb->posts .
\' WHERE \' . $wpdb->posts . \'.ID=\' . $pageId;
$post_data = $wpdb->get_results($nsquery);
if(!empty($post_data))
{
foreach($post_data as $post)
{
$text_out=nl2br($post->post_content);
$text_out=str_replace(\']]>\', \']]&gt;\', $text_out);
$text_out = strip_tags($text_out);
return substr($text_out,0,$max_char);

}
}
}
}
/* ********************************************** */
/* REGISTER SCRIPTS */
/* ********************************************** */
    function register_js() {
        if (!is_admin()) {
            wp_deregister_script(\'jquery\');
            wp_register_script(\'jquery\', \'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js\');
            wp_register_script(\'quicksand\', get_template_directory_uri() . \'/js/jquery.quicksand.js\', \'jquery\');
            wp_register_script(\'easing\', get_template_directory_uri() . \'/js/jquery.easing.1.3.js\', \'jquery\');
            wp_register_script(\'custom\', get_template_directory_uri() . \'/js/jquery.custom.js\', \'jquery\', \'1.0\', TRUE);
            wp_register_script(\'prettyPhoto\', get_template_directory_uri() . \'/js/jquery.prettyPhoto.js\', \'jquery\');
            wp_register_script(\'mousewheel\', get_template_directory_uri() . \'/js/jquery.mousewheel.js\', \'jquery\');
            wp_register_script(\'jscrollpane\', get_template_directory_uri() . \'/js/jquery.jscrollpane.js\', \'jquery\');


            wp_enqueue_script(\'jquery\');
            wp_enqueue_script(\'quicksand\');
            wp_enqueue_script(\'prettyPhoto\');
            wp_enqueue_script(\'easing\');
            wp_enqueue_script(\'custom\');
            wp_enqueue_script(\'mousewheel\');
            wp_enqueue_script(\'jscrollpane\');
        }
    }

    add_action(\'init\', \'register_js\');
/* ********************************************** */
/* REGISTER STYLES */
/* ********************************************** */
    function register_styles()
    {
        if (!is_admin()) {
            wp_register_style(\'prettyPhoto\', get_stylesheet_directory_uri() . \'/prettyPhoto.css\');
            wp_register_style(\'jscrollpane\', get_stylesheet_directory_uri() . \'/jquery.jscrollpane.css\');
            wp_enqueue_style( \'prettyPhoto\');
            wp_enqueue_style( \'jscrollpane\');
        }       
    }

    add_action(\'init\', \'register_styles\');

/* ********************************************** */
/* Jscrollpane Menu */
/* ********************************************** */

function my_in_head(){  ?>

    <script type="text/javascript">
    //<![CDATA[

    jQuery.noConflict();
    jQuery(document).ready(function($) { //tells WP to recognize the $ variable

    //paste your jquery code here
    $(\'#content\').not(\'body.home #content\').jScrollPane();
    }); //end document ready functions

    /* ]]> */
    </script>

<?php }
add_action(\'wp_head\', \'my_in_head\');
/* ********************************************** */
/* Exclude specific post */
/* ********************************************** */

function excludeposts() {
global $wp_query;

    if (is_home()) {
        $defaults = $wp_query->query_vars;
        $exclude = array(\'category__not_in\'=> array(5));
        $args = wp_parse_args( $exclude, $defaults );
        query_posts($args);
    }
}
add_action(\'thematic_above_indexloop\',\'excludeposts\');
/* ********************************************** */
/* Change default content display on home page to excerpt */
/* ********************************************** */
function childtheme_content($content) {
if (is_home() || is_front_page()) {
$content= \'excerpt\';}
return $content;
}
add_filter(\'thematic_content\', \'childtheme_content\');
/* ********************************************** */
/* Add read more Link  */
/* ********************************************** */
function new_excerpt_more($more) {
       global $post;
    return \'<a class="more-link" href="\'. get_permalink($post->ID) . \'">Read more...</a>\';
}
add_filter(\'excerpt_more\', \'new_excerpt_more\');
/* ********************************************** */
/* Dynamic sidebar for each page template  */
/* ********************************************** */
function is_pagetemplate_active($pagetemplate = \'\') {
global $wpdb;
$sql = "select meta_key from $wpdb->postmeta where meta_key like \'_wp_page_template\' and meta_value like \'" . $pagetemplate . "\'";
$result = $wpdb->query($sql);
if ($result) {
return TRUE;
} else {
return FALSE;
}
} // is_pagetemplate_active()

function test_template_widgets_init() {    
    if(is_pagetemplate_active(\'template-page-test.php\')) {

        register_sidebar( array (
            \'name\' => \'Test Widget Area\',
            \'id\' => \'test-widget-area\',
            \'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
            \'after_widget\' => "</li>",
            \'before_title\' => \'<h3 class="widget-title">\',
            \'after_title\' => \'</h3>\',
        ) );

    } // end test for active template
} // test_template_widgets_init()
add_action ( \'init\' , \'test_template_widgets_init\' );?>
我是否正确注册jquery和脚本?还是我错过了什么?谢谢

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

我就是这样做的,而且现在起作用了

function kia_enqueue_scripts() {

    //use google\'s jquery
    wp_deregister_script( \'jquery\' );
    wp_enqueue_script(\'jquery\', \'http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js\');

    //load up your own plugin
    wp_enqueue_script(\'easing\', get_stylesheet_directory_uri() . \'/js/jquery.easing.1.3.js\');
    wp_enqueue_script(\'custom\', get_stylesheet_directory_uri() . \'/js/jquery.custom.js\');
    wp_enqueue_script(\'mousewheel\', get_stylesheet_directory_uri() . \'/js/jquery.mousewheel.js\');
    wp_enqueue_script(\'jscrollpane\', get_stylesheet_directory_uri() . \'/js/jquery.jscrollpane.js\');

}
add_action(\'wp_enqueue_scripts\', \'kia_enqueue_scripts\');

结束

相关推荐

是否会使用AJAX从数据库中获取选项并在jQuery设置中使用它,或者是否有其他选择可供考虑?

我的主题中有一个滑块。我在选项中有一个设置,可以控制滑块是设置为“滑动”还是“淡入淡出”。这个幻灯片/淡入淡出设置在jquery中,当然选项设置也在数据库中。我认为获得此设置的正常方法是通过AJAX,但我想我会问,因为我有许多其他类似的关于此主题的场景。我一直认为AJAX的意思是“无需重新加载页面即可更改数据”。。。。但在这种情况下,我只希望jquery在第一次加载页面时能够访问数据。。。因此,我的“理解”似乎有点偏离,需要jqueryany time javascript/jquery需要从数据库中获取