functions.php not adding css to website?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
2
down vote

favorite
1












So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.



functions.php



<?php 
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');


}

add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


header.php



<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>




footer.php



        <footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>




fearnothing.css



 html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}

body{
padding: 20px;
}

h1{
color: yellow;
}









share|improve this question









New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • do you mean your CSS file is not added?
    – André Kelling
    Nov 21 at 8:35










  • Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
    – peter-cs
    Nov 21 at 8:36










  • to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
    – honk31
    Nov 21 at 9:00










  • ahh yes! it is called functions.php . will edit that now in the post!
    – peter-cs
    Nov 21 at 9:01

















up vote
2
down vote

favorite
1












So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.



functions.php



<?php 
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');


}

add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


header.php



<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>




footer.php



        <footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>




fearnothing.css



 html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}

body{
padding: 20px;
}

h1{
color: yellow;
}









share|improve this question









New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • do you mean your CSS file is not added?
    – André Kelling
    Nov 21 at 8:35










  • Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
    – peter-cs
    Nov 21 at 8:36










  • to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
    – honk31
    Nov 21 at 9:00










  • ahh yes! it is called functions.php . will edit that now in the post!
    – peter-cs
    Nov 21 at 9:01













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.



functions.php



<?php 
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');


}

add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


header.php



<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>




footer.php



        <footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>




fearnothing.css



 html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}

body{
padding: 20px;
}

h1{
color: yellow;
}









share|improve this question









New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.



functions.php



<?php 
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');


}

add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


header.php



<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>




footer.php



        <footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>




fearnothing.css



 html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}

body{
padding: 20px;
}

h1{
color: yellow;
}






php css






share|improve this question









New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 21 at 9:02





















New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 21 at 8:33









peter-cs

134




134




New contributor




peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






peter-cs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • do you mean your CSS file is not added?
    – André Kelling
    Nov 21 at 8:35










  • Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
    – peter-cs
    Nov 21 at 8:36










  • to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
    – honk31
    Nov 21 at 9:00










  • ahh yes! it is called functions.php . will edit that now in the post!
    – peter-cs
    Nov 21 at 9:01


















  • do you mean your CSS file is not added?
    – André Kelling
    Nov 21 at 8:35










  • Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
    – peter-cs
    Nov 21 at 8:36










  • to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
    – honk31
    Nov 21 at 9:00










  • ahh yes! it is called functions.php . will edit that now in the post!
    – peter-cs
    Nov 21 at 9:01
















do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35




do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35












Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36




Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36












to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00




to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00












ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01




ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.


For a theme, see example



function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );



For a plugin, see example



function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );



For both, add an external URL:



function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );





share|improve this answer






























    up vote
    1
    down vote













    I'm glad to know that you are having fun learning and building your own websites.



    Here is the deal:
    get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.



    The solution:
    If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().



    Your code should be like this:



    function fearnothing_script_enqueue(){
    wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


    }

    add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


    get_template_directory_uri() function Retrieve theme directory URI.
    For more information, you might take a look on codex documentation here






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "110"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      peter-cs is a new contributor. Be nice, and check out our Code of Conduct.










       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f319810%2ffunctions-php-not-adding-css-to-website%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote



      accepted










      I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.


      For a theme, see example



      function add_styles() {
      wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
      }
      add_action( 'wp_enqueue_scripts', 'add_styles' );



      For a plugin, see example



      function add_styles() {
      wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
      }
      add_action( 'wp_enqueue_scripts', 'add_styles' );



      For both, add an external URL:



      function add_styles() {
      // Add Google Fonts
      wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
      }
      add_action( 'wp_enqueue_scripts', 'add_styles' );





      share|improve this answer



























        up vote
        3
        down vote



        accepted










        I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.


        For a theme, see example



        function add_styles() {
        wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
        }
        add_action( 'wp_enqueue_scripts', 'add_styles' );



        For a plugin, see example



        function add_styles() {
        wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
        }
        add_action( 'wp_enqueue_scripts', 'add_styles' );



        For both, add an external URL:



        function add_styles() {
        // Add Google Fonts
        wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
        }
        add_action( 'wp_enqueue_scripts', 'add_styles' );





        share|improve this answer

























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.


          For a theme, see example



          function add_styles() {
          wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );



          For a plugin, see example



          function add_styles() {
          wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );



          For both, add an external URL:



          function add_styles() {
          // Add Google Fonts
          wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );





          share|improve this answer














          I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.


          For a theme, see example



          function add_styles() {
          wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );



          For a plugin, see example



          function add_styles() {
          wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );



          For both, add an external URL:



          function add_styles() {
          // Add Google Fonts
          wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
          }
          add_action( 'wp_enqueue_scripts', 'add_styles' );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 at 9:04

























          answered Nov 21 at 8:59









          Remzi Cavdar

          527213




          527213
























              up vote
              1
              down vote













              I'm glad to know that you are having fun learning and building your own websites.



              Here is the deal:
              get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.



              The solution:
              If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().



              Your code should be like this:



              function fearnothing_script_enqueue(){
              wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


              }

              add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


              get_template_directory_uri() function Retrieve theme directory URI.
              For more information, you might take a look on codex documentation here






              share|improve this answer

























                up vote
                1
                down vote













                I'm glad to know that you are having fun learning and building your own websites.



                Here is the deal:
                get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.



                The solution:
                If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().



                Your code should be like this:



                function fearnothing_script_enqueue(){
                wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


                }

                add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


                get_template_directory_uri() function Retrieve theme directory URI.
                For more information, you might take a look on codex documentation here






                share|improve this answer























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  I'm glad to know that you are having fun learning and building your own websites.



                  Here is the deal:
                  get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.



                  The solution:
                  If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().



                  Your code should be like this:



                  function fearnothing_script_enqueue(){
                  wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


                  }

                  add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


                  get_template_directory_uri() function Retrieve theme directory URI.
                  For more information, you might take a look on codex documentation here






                  share|improve this answer












                  I'm glad to know that you are having fun learning and building your own websites.



                  Here is the deal:
                  get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.



                  The solution:
                  If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().



                  Your code should be like this:



                  function fearnothing_script_enqueue(){
                  wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


                  }

                  add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');


                  get_template_directory_uri() function Retrieve theme directory URI.
                  For more information, you might take a look on codex documentation here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 21 at 9:04









                  Mahfuz

                  645




                  645






















                      peter-cs is a new contributor. Be nice, and check out our Code of Conduct.










                       

                      draft saved


                      draft discarded


















                      peter-cs is a new contributor. Be nice, and check out our Code of Conduct.













                      peter-cs is a new contributor. Be nice, and check out our Code of Conduct.












                      peter-cs is a new contributor. Be nice, and check out our Code of Conduct.















                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f319810%2ffunctions-php-not-adding-css-to-website%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Ellipse (mathématiques)

                      Quarter-circle Tiles

                      Mont Emei