Handle handling: wp_register_style() and wp_register_script(), do they need to be unique between the two or just within each separate function?
P粉478835592
P粉478835592 2023-09-06 23:17:28
0
1
591

Does anyone know if the handles in the wp_register_style and wp_register_script functions need to be unique in both functions, or just in their respective functions?

For example, will this code cause problems?

wp_register_style( 'bootstrap-twitter', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css', array(), '5.1.3');
wp_register_script( 'bootstrap-twitter' 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js', array( 'jquery' ) '5.1.3');

wp_enqueue_style( 'bootstrap-twitter' );
wp_enqueue_script( 'bootstrap-twitter' );

I didn't find the answer in the documentation and some online searches. I might just have a problem with my search though.

P粉478835592
P粉478835592

reply all(1)
P粉497463473

In WordPress, handles to styles and scripts are saved in different locations to avoid conflicting with each other. There is nothing wrong with your code.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!