在主题的文件函数中。php:
add_action(\'wp_enqueue_scripts\',\'STACK_356524_add_css_js_on_page\',99);
function STACK_356524_add_css_js_on_page(){
global $post;
if($post->post_type==\'page\') { // check if the current wp object is a `page` also is_page() can be used: see https://codex.wordpress.org/Conditional_Tags
wp_enqueue_script( \'js_handler\', \'url_of_your_script\', array(), \'\' );
wp_enqueue_style(\'css_handler\',\'url_of_your_style\',array(), \'1.0.0\', \'all\');
}
}
由您调整到正确的路径。css和。如果需要排队,可以查看脚本和文件所在的源页面并使用该字符串。可以进行更细粒度的调整(版本控制、依赖关系-即jquery,甚至只在特定页面上排队-即:
if( post->ID ==12345){}
.
有关详细信息:
https://developer.wordpress.org/reference/functions/wp_enqueue_script/https://developer.wordpress.org/reference/functions/wp_enqueue_style/
(IT)https://softrade.it/WP/wp_enqueue_script/