Errore quando si utilizza filemtime() con wp_enqueue_style
9 ago 2017, 12:44:58
Visualizzazioni: 15.8K
Voti: 13
Sto cercando di modificare la versione del file del foglio di stile utilizzando la funzione filemtime()
con wp_enqueue_style
tramite il seguente snippet
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory_uri() .'/child-style.css'), 'all' );
}
add_action( 'wp_enqueue_scripts', 'pro_styles' );
ma ricevo un warning
Warning: filemtime(): stat failed for.....
Nonostante sia sicuro che il file esista

Mohamed Omar
519
Tutte le risposte alla domanda
2
0
È perché lo stai recuperando tramite URL, ma filemtime()
richiede un percorso. Usa invece get_stylesheet_directory()
. Questa funzione restituisce un percorso:
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'), 'all' );
}
add_action( 'wp_enqueue_scripts', 'pro_styles' );

Jacob Peattie
43.9K
9 ago 2017 12:55:02
Domande correlate