Tagged: x
-
AuthorPosts
-
August 30, 2016 at 10:47 am #1153557
alriteamParticipantHello,
Please help me with adding js files. I have a js file which I duplicated and wants to add both the files.
Below is what I tried in function.php of child theme.
function child_scripts() {
wp_enqueue_script(‘main’,get_stylesheet_directory_uri().’/main.js’, array( ‘jquery’ ), null, false);
wp_enqueue_script(‘main1′,get_stylesheet_directory_uri().’/main1.js’, array( ‘jquery’ ), null, false);
}Wordpress – 4.5.3
X theme – 4.6.1
Cornerstone – 1.3Thanks in advance.
August 30, 2016 at 11:09 am #1153580
CMNerdsParticipantThis may be a silly question but did you create a folder for your custom js file in your child theme folder? If so, don’t forget to use that in your code (for example if you created a js folder then be sure to use js/main.js)
Give this a shot in your functions.php and let me know if it works.
function custom_scripts() { wp_register_script( 'custom-script', get_stylesheet_directory_uri() . 'YOUR-FILE-PATH-HERE.js', array() , false, true ); wp_enqueue_script( 'custom-script' ); } add_action( 'wp_enqueue_scripts', 'custom_scripts', 99 );August 30, 2016 at 11:11 am #1153590
CMNerdsParticipantOne more thing, I’m not sure if you started your functions.php in the child theme folder from scratch but make sure you are formatting your php file correctly:
<?php /* custom PHP functions start here */ ?>August 30, 2016 at 11:23 am #1153605
alriteamParticipantThis reply has been marked as private.August 30, 2016 at 11:29 am #1153619
ChristianModeratorPlease see http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/ to learn how to properly add scripts in WordPress.
Thanks.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1153557 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
