My stylesheets are not enqueuing
You can add stylesheet in back-office, but you need for that use the admin_enqueue_scripts action. See Codex reference : https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
You can add stylesheet in back-office, but you need for that use the admin_enqueue_scripts action. See Codex reference : https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
I think you have typo in your code: ors_enqueue_scripts should be wp_enqueue_scripts add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_theme_style’ ); function enqueue_parent_theme_style() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ ); wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri().’/style.css’ ); wp_enqueue_script(‘ors-animations’, get_stylesheet_directory_uri().’/javascripts/animations.js’, array( ‘jquery’ )); }
If do_action works, then the problem should be you are not calling wp_head() and wp_footer() in your header.php and footer.php respectively.
When shortcodes are evaluated, the header of the site has already been assembled. So if the shortcode wants to enqueue a script it must do so in the footer (by setting the last parameter to wp_enqueue_script to true. At this point you’re still not too late to prevent the file from actually being included in … Read more
Linking jquery code twice conflicts the functions as they are present twice. So deregistering helps you but it is not good choice. You should go through jQuery no conflict thing. And you should register your jquery version with different name, so that it does not break wordpress. Ref- jQuery Forum and Documentation
To use wp_enqueue_script() correctly, you need to launch your function with the action wp_enqueue_scripts. In your __construct() or init function add_action(‘wp_enqueue_scripts’, array($this, ‘admin_script’)); You can enqueue both, scripts and styles, in this function.
…if it’s a good practice to load the main theme styles this way, since usually they’re hardcoded into the header before anything else. Long story short, yes. WordPress advocates the enqueue “API” for all assets whenever possible.
It was syntex error in my functions.php which causing the error. In the if statement it was not wp_enqueue_scripts. It was wp_enqueue_script
Starting from WordPress 4.7, I would use get_theme_file_uri(), so any child theme can override the file easily: if the file exists in the child theme, get_theme_file_uri() returns the URI to that file, otherwise returns the file in the parent theme: wp_enqueue_script( ‘localScroll’, get_theme_file_uri( ‘js/jquery.localScroll.min.js’ ), array( ‘scrollTo’ ), ‘1.2.8b’, true ); If you want to … Read more
Printing the script in the head is a method called do_item in the wp_script class. In this method you see this line: $tag = “{$cond_before}{$before_handle}<script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/262406/$src”></script>\n{$after_handle}{$cond_after}”; So, the script type is hardwired in the function. However, a few lines further on, you see this: $tag = apply_filters( ‘script_loader_tag’, $tag, $handle, $src ); This allows … Read more