I’m brand new at theme development. My css stylesheet is not loading, and I’m not sure if the problem is in the functions.php, style.css, index.php, header.php, or footer.php file. I’ve added a div class “post-title” in index.php, which should change the font color of my posts, but right now it’s not doing that. My code is below:

functions.php:

            <?php
                function link_css_stylesheet() {
                    wp_enqueue_style('style', get_stylesheet_uri());
                }

                add_action('wp_enqueue_scripts', 'link_css_stylesheet');
            ?>

style.css:

            /*
            Theme Name: Richard Theme Name
            Theme URI: http://www.intechio.com/themes/Richard-Theme
            Author: Richard
            Author URI: https://intechio.com
            Description: Theme project.  
            Version: 1.0
            */

            .post-title {
                color : rgb(0,100,0);
            }

index.php:

            <?php
                get_header();
                ?>

                <div class="post-title">

                    <?php

                    if (have_posts()) : 
                        while (have_posts()) : the_post();
                            the_title();
                            the_excerpt();
                        endwhile; 
                    else: 
                        echo "No posts.";
                    endif;

                    ?>

                </div>

                <?php
                get_footer();
            ?>

header.php:

            <!DOCTYPE html>
                <html>
                    <head>
                        <meta charset=”<?php bloginfo(‘charset’); ?>
                        <title><?php wp_title(); ?> | <?php bloginfo('name'); ?></title>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
                        <?php wp_head(); ?>
                    </head>
                        <body <?php body_class(); ?>>
                            <h1><?php bloginfo(‘name’); ?></h1>
                            <h2><?php bloginfo(‘description’); ?></h2>

footer.php:

            <p>this is a footer</p>
            </body>
            </html>

Thank you in advance for any tips you might be able to offer.

5 Answers
5

I have tried to create WordPress theme using your functions.php, style.css and index.php and for me, the stylesheet is loading correctly. Please make sure you have added your header.php and footer.php for the theme.
Please study some tutorials for theme development on WordPress.You can look at this link https://codex.wordpress.org/Theme_Development
for detailed information.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *