• Ogłoszenie:

Wp_head not injecting css

Wszystko odnośnie tworzenia grafiki - obróbka, problemy, oceny.
Tworzenia Stron internetowych - HTML, PHP, MySQL...

Wp_head not injecting css

Postprzez TeetharKehar 23 Sty 2023, 12:21

reklama
I'm trying to inject a style.css script into my front-page.php. I am able to load front-page's content by not link the style.css.

When you inspect page source, all the CSS should be there, but it simply shows the wp_head() script without injecting anything.

My functions.php, front-page.php, and style.css are all in the same root directory.

front-page.php

<head>
<php?
wp_head();
?>
</head>
** Edited the functions.php file**

<?php

function load_scripts(){
wp_enqueue_style('style', './style.css' );
}

add_action( 'wp_enqueue_scripts', 'load_scripts');
?>
Added <php? wp_head(); ?> to the front-page.php in the head tag.

<head>
<php? wp_head(); ?>
</head>
style.css sheet

/*
Theme Name: InfluencerSite
Text Domain: InfluencerSite
Version: 1.0
Description: Fancy stuff
Tags: left-sidebar, responsive, fancy
Author: Shawn Esquivel
Author URI: github.com/shawnesquivel
*/


.testing {
color: red;
}

Other Things I tried adding into the functions.php script

wp_enqueue_style('anydescription', get_stylesheet_uri(), array(), "1.0", 'all');


wp_enqueue_style('any-style-name', get_stylesheet_uri());

wp_enqueue_style("style", get_template_directory_uri() . "./style.css");
TeetharKehar
~user
 
Posty: 24
Dołączenie: 02 Sty 2023, 12:06



Wp_head not injecting css

Postprzez TeetharKehar 12 Paź 2023, 06:15

First, make sure that your style.css file is in the correct location. It should be in the same directory as your functions.php file and your front-page.php file.

Next, check your functions.php file to make sure that you are enqueueing your style.css file correctly. You can do this by adding the following code to your functions.php file:

PHP
function load_scripts(){
wp_enqueue_style('style', get_stylesheet_uri() );
}

add_action( 'wp_enqueue_scripts', 'load_scripts');
Use code with caution. Learn more
This code will enqueue your style.css file on all pages of your WordPress site.

Finally, make sure that you are calling the wp_head() function in the head section of your front-page.php file. You can do this by adding the following code to the head section of your front-page.php file:

PHP
<?php
wp_head();
?>
Use code with caution. Learn more
This code will print the necessary header information for your WordPress site, including the CSS code from your style.css file.

If you have tried all of the above and your style.css file is still not injecting into your front-page.php file, please try the following:

Clear your WordPress cache.
Disable any WordPress plugins that you are using.
Switch to a different WordPress theme.
If you are still having problems, please provide more information about koowspin echatrandom your WordPress setup, such as the version of WordPress that you are using and the version of your theme.
TeetharKehar
~user
 
Posty: 24
Dołączenie: 02 Sty 2023, 12:06




Powróć do Grafika & Webmastering

Kto jest na forum

Użytkownicy przeglądający to forum: Brak zarejestrowanych użytkowników oraz 1 gość