• I am creating a custom theme from scratch and need to know how to add the basic css/stylesheet to my files/folders. Here is the code I have:
    Functions PHP
    <?php

    function puzld_script_enqueue() {

    wp_enqueue_style(‘customstyle’, get_template_directory_uri() . ‘/css/puzld.css’, array(), ‘1.0.0’, ‘all’);
    wp_enqueue_script(‘customjs’, get_template_directory_uri() . ‘/js/puzld.js’, array(), ‘1.0.0’, true);
    }

    add_action(‘wp_enqueue_scripts’, ‘puzld_script_enqueue’);

    function puzld_theme_setup() {
    add_theme_support(‘menus’);
    register_nav_menu(‘primary’, ‘Header’);
    register_nav_menu(‘primary2’, ‘Header2’);
    register_nav_menu(‘secondary1’, ‘Footer’);
    register_nav_menu(‘secondary’, ‘Footer2’);
    }

    add_action(‘init’, ‘puzld_theme_setup’);

    add_theme_support(‘custom-background’);
    add_theme_support(‘custom-header’);
    add_theme_support(‘post-thumbnails’);

    I have a feeling that I need to change the:
    wp_enqueue_style(‘customstyle’, get_template_directory_uri() . ‘/css/puzld.css’, array(), ‘1.0.0’, ‘all’);
    wp_enqueue_script(‘customjs’, get_template_directory_uri() . ‘/js/puzld.js’, array(), ‘1.0.0’, true);
    }
    to something else. Maybe getting rid of the wp_enqueue_script… and changing the customstyle and ‘/css/puzld.css’ to something else. I don’t want to use bootstrap and I believe that is what this is setting me up for.
    I believe if this is changed properly I could just use the style.css file for my css coding. ???

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Your code looks fine at first glance. What in particular isn’t working? You also aren’t required to use Bootstrap, and none of the code you posted would load Bootstrap anyway.

    One thing you could do would be to use get_stylesheet_uri() instead; it’s the same as get_template_directory_uri() . '/style.css':

    wp_enqueue_style( 'customstyle', get_stylesheet_uri(), array(), '1.0.0', 'all' );

    Thread Starter Shawn Ritch

    (@shawn-ritch)

    Thanks for the advice, and so quick! I took your advice and it didn’t break anything lol; However, now I need to know the appropriate css to add to the style.css file to get started. Everything I add has no effect on the look of the site.
    The problem is when I try to add css to my style.css file nothing is happening :/ here is the url of the site: https://ursocialx.com

    I have to leave soon, but when I checked out your site, there’s a 404 error for both your stylesheet and your JavaScript. Here’s where WordPress is looking for your files:

    wp-content/themes/puzld.com/css/puzld.css?ver=1.0.0 and wp-content/themes/puzld.com/js/puzld.js

    What is the file structure of wp-content/themes?

    Thread Starter Shawn Ritch

    (@shawn-ritch)

    You looked at the site before I changed the files. Please check again…
    Although, here is the structure now:

    Templates

    comment-template.php
    Comments
    (comments.php)
    Theme Footer
    (footer.php)
    Theme Functions
    (functions.php)
    Theme Header
    (header.php)
    Main Index Template
    (index.php)
    Front Page Template
    (page-front.php)
    Home Page Template
    (page-home.php)
    Profile Page Template
    (page-profile.php)

    Styles

    Stylesheet
    (style.css)

    What is the current code in your functions.php? You don’t need to append anything to get_stylesheet_uri(); it’s enough to simply call get_stylesheet_uri().

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding css/stylesheet to a custom theme I'm builing from scratch’ is closed to new replies.