1

These Enqueue script I want to load these code on HTML in a specific page. For me its not working. I implement the code by activating child theme

    function child_post_themes_styles() {

    wp_enqueue_style( 'reset_css', get_template_directory_uri() . '/css/resetx.css' );
    wp_enqueue_style( 'style_css', get_template_directory_uri() . '/css/stylex.css' );

    }
    add_action( 'wp_enqueue_scripts', 'child_post_themes_styles' );

    function child_post_themes_js() {

    wp_enqueue_script( 'modernizer_js', get_template_directory_uri() . '/js/modernizerx.js', '', '', false );
    wp_enqueue_script( 'main_js', get_template_directory_uri() . '/js/mainx.js', '', '', false );
    wp_enqueue_script( 'jquery2_js', get_template_directory_uri() . '/js/jquery-2.1.1x.js', 'array('jquery')', '', true );
    wp_enqueue_script( 'jquerymobile_js', get_template_directory_uri() . '/js/jquery.mobilex.custom.min.js', 'array('jquery')', 'jquery2_js', '', true );

    }
    add_action( 'wp_enqueue_scripts', 'child_post_themes_js' );
2

2 Answers 2

1
    function child_post_themes_styles() {

    wp_enqueue_style( 'reset_css', get_stylesheet_directory_uri() . '/css/resetx.css' );
    wp_enqueue_style( 'style_css', get_stylesheet_directory_uri() . '/css/stylex.css' );

    }
    add_action( 'wp_enqueue_scripts', 'child_post_themes_styles' );

    function child_post_themes_js() {

    wp_enqueue_script( 'modernizer_js', get_stylesheet_directory_uri() . '/js/modernizerx.js', '', '', false );
    wp_enqueue_script( 'main_js', get_stylesheet_directory_uri() . '/js/mainx.js', '', '', false );
    wp_enqueue_script( 'jquery2_js', get_stylesheet_directory_uri() . '/js/jquery-2.1.1x.js', 'array('jquery')', '', true );
    wp_enqueue_script( 'jquerymobile_js', get_stylesheet_directory_uri() . '/js/jquery.mobilex.custom.min.js', 'array('jquery')', 'jquery2_js', '', true );

    }
    add_action( 'wp_enqueue_scripts', 'child_post_themes_js' );

get_template_directory_uri will always refer to the parent theme folder for assets. get_stylesheet_directory_uri will refer to the "current" theme folder for assets (which could be the parent or the child, depending on where it is called).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks very much Sco
After addding the css file. Header menu alignment problem occurs. Any olution>?
0

You can create the file functions.php in child theme folder.

After put the function on functions.php file in child theme folder

add_action( 'wp_enqueue_scripts', 'child_post_themes_styles' );
function child_post_themes_styles() {
	wp_enqueue_style( 'reset-css', get_template_directory_uri().'/css/resetx.css' );
	wp_enqueue_style( 'style-css', get_template_directory_uri().'/css/stylex.css' );
	wp_enqueue_script( 'modernizer-js', get_bloginfo( 'stylesheet_directory' ).'/js/modernizerx.js', array( 'jquery' ), '', false );
	wp_enqueue_script( 'main-js', get_bloginfo( 'stylesheet_directory' ).'/js/mainx.js', array( 'jquery' ), '', false );
	wp_enqueue_script( 'jquery2-js', get_bloginfo( 'stylesheet_directory' ).'/js/jquery-2.1.1x.js', array( 'jquery' ), '', true );
	wp_enqueue_script( 'jquerymobile-js', get_bloginfo( 'stylesheet_directory' ).'/js/jquery.mobilex.custom.min.js', array( 'jquery' ), '', true );
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.