• Resolved Truck35

    (@truck35)


    I am trying to create a custom theme template and I am having trouble styling my blog page. I got my header, footer index and function php files. And, I also have my style.css file. I have the necessary comments at the beginning of my css file and I am using the following code in my function php file to link my style sheet to my page:

    <?php
    function link_resources()
    {
    	wp_enqueue_style('style', get_stylesheet_uri());
    }
    
    add_action('wp_enqueue_scripts', 'link_resources');
    ?>

    Here is a copy of what is in my css file:

    *
    Theme Name: Hopeful
    Author: Kevin Haynes
    Author URI: https://www.stay-hopeful.com
    Version: 1.0
    */
    
    h1{
    	text-align:center;
    	font-size:100px;
    	font-family:Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    	color:blue;
    	margin-top:200px;
    }

    for now I’m just tring to style the h1 tag but, I can’t even get that much done.
    Could any one help?

    Thanks,
    Truck35

Viewing 13 replies - 1 through 13 (of 13 total)
  • In the style.css file you started with: *
    Instead of: /*

    Was it a copy paste problem or you have like that in your code?

    Thread Starter Truck35

    (@truck35)

    It was a copy an paste problem. It sould be: /*.

    Do you have a link?
    Did you activate the right theme on the administration?

    Thread Starter Truck35

    (@truck35)

    I am working of my local computer so, I don’t know if it is possible to have a link. I did activate the theme in the administration. I see the name of the theme and version etc. in administration page where you choose your theme but, when I view my theme, it does not recognize the style sheet. I used fire bug and it confirms that the style sheet is not being recognized. However, I can style the page using firebug.

    Do you have the style.css on the root of the theme folder?
    What error do you have on firebug? What path does it show for style.css?

    Thread Starter Truck35

    (@truck35)

    The style.css is in the root directory of the folder that I created for my theme. Firebug just shows that there is no style sheet attached to the page. I don’t know what path is shown for my style.css file. Does the “get_stylesheet_uri()” method return the path when called? If so, then I can echo it and see what path it is returned or, if there is a better way maybe you can let me know.

    Thanks,
    Truck35

    No, I mean, if you have firebug open, go to Network tab and you should find there style.css file with its path and the error code.

    Thread Starter Truck35

    (@truck35)

    I am assuming the “Net” tab in firebug is the one you are referring to. I enabled it and viewed the tab’s content and it did not show any file or path. I perplexed, I even tried using a link tag in the header and still can’t make any changes using my style sheet.

    After enabling the Net tab you must refresh the page so that you can see all the resources that are being loaded.
    At least, the page itself should show up on that list.

    You can do one more thing, right click any where on the site and View Source. Check the url that was generated for link tag of the style.css file. Also check if you can open that url directly in the browser.

    I posted on your other thread about this issue; did you see it? https://www.ads-software.com/support/topic/cant-get-style-sheet-to-link-to-index-page?replies=2

    Also, is your file named functions.php? Note the plural.

    Thread Starter Truck35

    (@truck35)

    Sorry for all the confusion with the second post. I did see the replies from the second post. My file is called function.php. I right clicked and selected view source file and I do not see any reference to a link to my style.css file. I echoed the return value of my “wp_enqueue_style(‘style’, get_stylesheet_uri())” function in my index.php file and it returned a styled version of my page using the css that I have in my “style.css” file. I also went to the “Net” tab in firebug and refreshed my page after loading my page and it displayed some information that I am unfamiliar with.

    If you take this code:

    <?php
    function link_resources()
    {
    	wp_enqueue_style('style', get_stylesheet_uri());
    }
    
    add_action('wp_enqueue_scripts', 'link_resources');
    ?>

    out of index.php and place it in a file named functions.php (note the plural; it’s very important), does it work correctly?

    Thread Starter Truck35

    (@truck35)

    I changed the name of my file from function.php to functions.php and everything is working fine now. I did not realize what you meant at first when you put the not that said to make sure the name is plural.

    Thanks for everyone that helped me.

    Bless,
    Truck35

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘page will not reconize CSS style sheet’ is closed to new replies.