您可以在functions.php中拥有一个小的函数,该函数将根据一周中的某一天使您的脚本入队。 就像是:
function myFunc(){
$todaysDay = intval(date('N')); // 'N' returns current day as number we convert it to int
// we check if it's Monday(1) or Wednesday(3)
if($todaysDay === 1 || $todaysDay === 3){
//if yes enqueue our script
wp_enqueue_script( 'myJs', get_theme_root_uri() . '/my_theme/path_to_myFile/myJs.js', array(), false);
}
}
add_action( 'init', 'myFunc' );