Page 1 of 1

wordpress stylesheet linking

Posted: Thu Mar 31, 2016 5:47 pm
by gautamz07
I was just going through this tutorial https://www.youtube.com/watch?v=k7olvEe ... aqOVpX7qi5 and basically the author recommends that the css stylesheet be imported like so:

Code: Select all

<?php
    function learningWordPress_resources() {
        wp_enqueue_style('style' , get_stylesheet_uri());
    }
    add_action('wp_enqueue_scripts' , 'learningWordPress_resources');
?>
My header.php of my theme looks like so:

Code: Select all

<!doctype html>
<html <?php  language_attributes(); ?> >
    <head>
        <meta charset="<?php  bloginfo('charset');   ?>">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title><?php bloginfo('name');  ?></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">        

        <?php  wp_head(); ?>

    </head>
    <body <?php  body_class(); ?>>



    <header class="site-header">
        <h1><a href="<?php echo home_url(); ?>"></a><?php bloginfo('name');  ?></h1>
        <h5><?php bloginfo('description'); ?></h5>
    </header>
But i am still not seeing the effect of my stylesheet , can anybody point me to what exactly am i doing wrong ?

Thank you.

Re: wordpress stylesheet linking

Posted: Sun Apr 03, 2016 5:33 am
by gautamz07
EDIT:: On further inspection i found out that if i post the contents of header.php in index.php the stylesheet is loading fine , which means that my functions.php files is working fine. So i guess the problem is with my header.php file, I have updated above what my header.php file looks like, so can somebody tell me whats wrong with my header.php file now ?

Re: wordpress stylesheet linking

Posted: Sun Apr 03, 2016 7:27 am
by Celauran
gautamz07 wrote:On further inspection i found out that if i post the contents of header.php in index.php the stylesheet is loading fine
This suggests that your header.php file is also fine, but possibly not being loaded, so the problem may lie in your index.php

Re: wordpress stylesheet linking

Posted: Tue Apr 05, 2016 9:23 pm
by cybershot
does your index.php file have something like this

Code: Select all

get_header();
if not, it needs it. Place that line of text at the very top of your index.php file before anything else and that should solve it. Also make sure that your index file has one for the footer

Code: Select all

get_footer();
placed at the very end of the index.php file

Re: wordpress stylesheet linking

Posted: Sun Apr 10, 2016 12:01 pm
by gautamz07
@celauran and @cybershot , you guys were right , i found out that i was missing the following:

get_header();

Re: wordpress stylesheet linking

Posted: Fri Apr 15, 2016 10:10 am
by tamziedahmed
Use <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" /> and then @import the additional stylesheets at the top of style.css after the theme data block.