Best Premium and Free WordPress Themes › Forums › SuperMagPro › Having issues with creating subtheme or enquing any js/css in function.php
- This topic has 3 replies, 2 voices, and was last updated 6 years, 11 months ago by
acmesupports.
- AuthorPosts
- March 8, 2016 at 10:38 am #4795
foot01
MemberHi,
My client bought this theme and I have a few problems with loading css / js
I’ve been trying several ways to make subtheme…
And I couldn’t find a way to load a style-subtheme.css without squashing theme style.css
So I gave up and stared hacking directly in the theme… uggly (I rely on git… oufff)now I’ve had to create a widget and I hit again the same issue when I need to load a js.
I’ve added this in function.php but doesn’t seem to do anything
function widget_filinfo_load_js()
{// Register the script like this for a theme:
wp_register_script( ‘filinfo-script’, get_template_directory_uri() . ‘/filinfo/filinfo.js’, array( ‘jquery’ ) );
}
add_action( ‘wp_enqueue_scripts’, ‘widget_filinfo_load_js’ );Thanks for your help
Regards
Antony
March 8, 2016 at 10:48 am #4797acmesupports
ModeratorHello,
Thank you so much for using our theme SuperMagPro. Some line of code is mistake there. So please use the below code while enqueue style and scripts.add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_script( ‘child-custom-js’, get_stylesheet_directory_uri() . ‘/child-custom.js’, array(‘jquery’), false, ‘1.0.0’ );
}If you feel any problem, please feel free to ask.
Best Regards,
Acme SupportsMarch 8, 2016 at 11:00 am #4796foot01
MemberI finally figured out a solution
by using wp_enqueue_script in place of wp_register_script
it seems to work fine
- AuthorPosts
- You must be logged in to reply to this topic.