Search code examples
htmlwordpresswordpress-themingcustom-wordpress-pagesphp-enqueue

enqueue_stylesheet but it is not working on wordpress theme development


i have recently download a theme and try to convert it into wordpress theme.

now i got stuck in error i am trying to enqueue my style sheet script into theme and its not working.

this is my header where i use wp_head() tag to hook my enqueue function

<!DOCTYPE html>
<html dir="ltr" lang="en-US">

<head>

  <meta http-equiv="content-type" content="text/html; charset=utf-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <!-- Document Title
    ============================================= -->
  <title>Index Template</title>
  <!-- <link rel="stylesheet" href="" type="text/css" /> -->
  <?php wp_head(); ?>

</head>

this is my load style sheet function code and add_action function is use to hook the function to header

function ft_loadScripts()
{
    wp_register_style( 'ft_style', get_stylesheet_uri() );
    wp_enqueue_style( 'ft_style' );
}

add_action( 'wp_enqueue_scripts','ft_loadScripts' );

This is my main style sheet created for theme it is loacated in theme folder
in this style sheet i use only body backgound color to test the code .

/*
Theme Name: Firstweb
Theme URI: https://wordpress.org/themes/Firstweb/
Author:John don
Author URI: https://wordpress.org/
Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: Firstweb
*/

body{
    background-color: black;
}

This my folder structure

enter image description here

In assets folder

enter image description here

This is how my theme look like

enter image description here

but i don't know why its not working. i also check in developer tool there is no error of style sheet in console but still the style sheet in not working at all

somebody plz help me with this Thank You in advance


Solution

  • From what I can see, the code snippets should all work fine. However, it looks like your functions.php is called function.php (without the ‘s’), causing Wordpress to ignore the file. Hopefully renaming the file fixes your issue!