I have been trying to create a WordPress theme but linking to style.css within header.php doesn't seems to work, the header just doesn't appear. Used more than 30 codes even the ones provided by WordPress and people with similar errors but it seems like the solutions are outdated.

<link href="<?php bloginfo('stylesheet_url'); ?>" rel = "stylesheet"> 

This is my PHP script

<!DOCTYPE html> <html> <head> <title>Welcome</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet"> </head> <body> <div> <div> <a href="#">Logo</a> <button> <span></span> <span></span> <span></span> </button> <div> <ul> <li><a href="#">Home</a> </li> <li><a href="#">Contact</a> </li> <li> <a href="#">Social Media<b class = "caret"></b></a> <ul> <li><a href="#">Facebook</a> </li> <li><a href="#">Instagram</a> </li> <li><a href="#">Twitter</a> </li> <li><a href="#">Google Plus</a> </li> </ul> </li> <a href="">Add</a> </ul> </div> </div> </div> <div> 
1

8 Answers

Your theme style.css is included by default by the WordPress by wp_head() function. Before you end your HEAD tag add this function.

<?php wp_head(); ?> 

If you want to add additional stylesheets then use this function in your functions.php file.

function additional_custom_styles() { /*Enqueue The Styles*/ wp_enqueue_style( 'uniquestylesheetid', get_template_directory_uri() . '/css/custom.css' ); } add_action( 'wp_enqueue_scripts', 'additional_custom_styles' ); 
3

Have you tried:

<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(). '/style.css' ?>"> 

And have that file (I usually place it in a header.php file) in the same directory as the style.css file?

This is what I do.

2

For me this works great:

<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory"); ?>/style.css" /> 
2

you can try this one

 <?php echo get_stylesheet_uri(); ?> 

instead of this

<?php bloginfo('stylesheet_url'); ?> 

from here

make sure your style.css file is in your theme's directory

0

Use the following code

<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" /> 

Hope that helps

3

Put the following under wp_head();

<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" /> 

refer to update the fuction.php file through the Wordpress Dashboard > Appearance > Theme Editor theme files are listed on the right.

add the following to your function.php file

wp_enqueue_style ('style-name', get_template_directory_uri().'/mystylefile.css');

flush your word press cache and make sure you FTP the file up to the root of the theme.

Just include this in the header, don't put style.css here

<?php wp_enqueue_style( 'style', get_stylesheet_uri() ); ?> 

if you are adding Bootstrap CDN then use that like this

<link rel="stylesheet" type="text/css" href=""> 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy