Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link to CSS properly in WordPress header.php?

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 class="navbar navbar-default navbar-static-top">
        <div class="container"> <a href="#" class="navbar-brand">Logo</a>

            <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"> <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <div class="collapse navbar-collapse navHeaderCollapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="#">Home</a>
                    </li>
                    <li><a href="#">Contact</a>
                    </li>
                    <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Social Media<b class = "caret"></b></a>

                        <ul class="dropdown-menu">
                            <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="http://www.adds.com" class="navbar-btn btn-success btn pull-right">Add</a>

                </ul>
            </div>
        </div>
    </div>
    <div class="container">
like image 458
Samuël Avatar asked Aug 08 '14 06:08

Samuël


1 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' );
like image 180
dipak_pusti Avatar answered Sep 18 '22 15:09

dipak_pusti