Answer the question
In order to leave comments, you need to log in
Why is wp_enqueue_style() incorrect output of attached file link when running on XAMPP?
Hello, dear users of the "Toaster" service.
I work on a local computer via XAMPP, Windows operating system, I connect style files through the wp_enqueue_style () function, but the file is not connected correctly, the tag is displayed
<link rel='stylesheet' id='vcas_testimonial-css' href='http://localhost/my-syte.ruC:xampphtdocsrvision.prowp-contentthemesrvisionincludesvc_extend/assets/css/vcas_testimonial.css?ver=4.8.1' type='text/css' media='all' />
instead of<link rel='stylesheet' id='vcas_testimonial-css' href='http://localhost/my-syte.ru/wp-content/themes/rvision/includes/vc_extend/assets/css/vcas_testimonial.css?ver=4.8.1' type='text/css' media='all' />
add_action('wp_print_styles', 'add_vc_styles');
function add_vc_styles() {
if(is_admin()) return false;
$dir = plugin_dir_path( __FILE__ ) . "assets/css/";
$files = scandir( $dir, 1 );
foreach ( $files as $file ) {
if ( "." !== $file && ".." !== $file ) {
$file_path = $dir . $file;
if ( is_file( $file_path ) ) {
$file_name = pathinfo($file, PATHINFO_FILENAME);
wp_enqueue_style($file_name, $file_path);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
plugin_dir_path method - returns the local path to the file. Needed to connect php files.
Use plugin_dir_url to get link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question