Zdravím,
trošku bojuji s načtením CSS a JS do vlastní WordPress šablony.
Mám přidané CSS a JS s pomocí tohoto kódu ve functions.php
:
wp_register_style( 'bootstrap-css', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css', false);
wp_register_style( 'my-css', get_stylesheet_uri(), false);
wp_register_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ));
wp_enqueue_style( 'bootstrap-css' );
wp_enqueue_style( 'my-css' );
wp_enqueue_script( 'bootstrap-js' );
Bohužel, z nějakého, pro mě záhadného důvodu se css styly aplikují i na administraci, což vůbec nechci.
Zkoušel jsem i jiný kód a to konkrétně tento podle WP dokumentace: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
function themeslug_enqueue_style() {
wp_enqueue_style( 'bootstrap.min', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css', false );
wp_enqueue_style( 'style', get_stylesheet_uri(), false );
}
function themeslug_enqueue_script() {
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . 'bootstrap/js/bootstrap.min.js', false );
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );
Bohužel tady u toho zase nefunguje JS.
Takže už tápu a nevím, jak toto linkování JS a CSS vlastně funguje :(
Děkuji mockrát za každou pomoc