douluan1533 2017-04-06 15:04
浏览 34

将网站转换为Wordpress时,我的custom.js无效。 我正在使用正确的方法,通过在functions.php中链接

I am currently learning to create themes for Wordpress and I'm trying to link my custom.js file via the functions bit but it's just not working.

<?php

function additional_custom_styles() {

    /*Enqueue The Styles*/
    wp_enqueue_style( 'themename', get_template_directory_uri() . '/css/main.css' );
    wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css' );
    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.js', array( 'jquery' ), '3.3.6', true );

}

add_action("wp_enqueue_scripts", "launch_scripts");
    function launch_scripts() {
        $internal_path = get_template_directory_uri() . '/js/';
        wp_enqueue_script('main-script', $internal_path . 'custom.js', array(''));
    }

add_action( 'wp_enqueue_scripts', 'additional_custom_styles' );

function mytheme_customize_register( $wp_customize ) {
    $wp_customize->add_section( 'themeslug_logo_section' , array(
        'title'         => __( 'Logo', 'themeslug' ),
        'priority'      => 30,
        'description'   => 'Upload a logo to replace the default site name and description in the header',
    ));
    $wp_customize->add_setting( 'themeslug_logo' );
    $wp_customize->add_control( new WP_Customize_Image_Control(
        $wp_customize, 'themeslug_logo', array(
            'label'     => __( 'Logo', 'themeslug' ),
            'section'   => 'themeslug_logo_section',
            'settings'  => 'themeslug_logo',
        )
    ));
}
add_action( 'customize_register', 'mytheme_customize_register' );

?>

http://wordpress.taylorgathercole.co.uk - link to the Wordpress. The .js file has scripts to allow the navigation to change on scroll etc.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统