why wp_enqueue_scripts() not working?

Hey bro Use this code get_stylesheet_directory_uri function custom_theme_script(){ wp_register_style(‘bootstrap’, get_stylesheet_directory_uri.() .’/css/bootstrap.css’ ); wp_enqueue_style(‘bootstrap’); wp_register_style(‘style’, get_stylesheet_directory_uri() . ‘/css/style.css’); wp_enqueue_style(‘style’); wp_deregister_script( ‘jquery’ ); wp_enqueue_script(‘bootstrap.min’, get_template_directory_uri() . ‘/js/bootstrap.min.js’, array(), ‘3.5.1’, true ); } add_action(‘wp_enqueue_scripts’, ‘custom_theme_script’); `

How to make my shortcode load scripts and styles, from within the plugin?

plugins_url expects the second parameter to be the main plugin file, which is why __FILE__ is used in examples, it’s assuming the code is in that file, but yours is not. To fix this, you will need to retrieve __FILE__ in your main plugin file, store it, and pass it to your shortcode objects for … Read more

wp_dequeue_script for a Plugin

It still displays the script because you are using the wrong hook (and it doesn’t exist) — wp_dequeue_scripts, and secondly, if the script is indeed enqueued via wp_enqueue_script(), then the generated id (used in the <script> tag) is in the form of <script handle>-js (i.e. suffixed with a -js) where <script handle> is the first … Read more

How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)

Try using is_post_type_archive() and is_singular(): // … if ( is_post_type_archive( ‘my-post-type’ ) || is_singular( ‘my-post-type’ ) ) { // your enqueue code goes here } // … These functions will check to see if you’re on, respectively, an archive page for the post type my-post-type or a single my-post-type post. (Change the my-post-type to what … Read more

403 error When i send ajax request on WordPress website

Short answer — how can you solve the problem: When you call check_ajax_referer(), use secure_nonce_name as the first parameter, i.e. check_ajax_referer( ‘secure_nonce_name’, ‘security’ ). A Longer Answer The first parameter (which is the nonce action) for check_ajax_referer() needs to match the first parameter for wp_create_nonce(), but in your code, they are secure-nonce-name and secure_nonce_name respectively, … Read more

How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]

The error describes WordPress attempting to execute an action resulting in Enqueue::css() receiving too few arguments (it requires at least two). In the constructor you are hooking Enqueue::css() to the wp_enqueue_scripts action. When wp_enqueue_scripts is executed, it receives no additional arguments, so it calls Enqueue::css() with no arguments, triggering the error. Long story short, all … Read more

Add type to enqueued script inside plugin

There’s a filter: script_loader_tag. add_filter( ‘script_loader_tag’, ‘wpse397773_change_script_tags’, 10, 3 ); function wpse397773_change_script_tags( $tag, $handle, $src ) { $tag = ‘<script type=”text/plain” src=”‘ . $src . ‘” id=”‘ . $handle . ‘-js”></script>’; return $tag; } This should change all the <script> tags in the page (assuming they’re properly enqueued) to <script type=”text/plain”>. Update: To only change … Read more