5

I suddenly got got an error when coding - wordpress -> theme: enter image description here

I don't understand why this is the case as I have an index.php page. Also the css stylesheet is there as well. style.css also has the following commented

style.css

Theme Name: samirTheme
Author: samir
Author URI: www.wordpress.com
Version: 1.0
Description: This is a cool theme
Template: Test1

Here is the folder structure

enter image description here

New to wordpress. So confused as to why the theme is broken and not showing up in wordpress. Any ideas?

8
  • you are missing a template.php and style.css
    – Mario
    Apr 8, 2017 at 21:40
  • 1
    But I have style.css in the css folder. I didn't have template.php this whole time and the theme was working i.e. not broken and active. Why now would it break
    – Shaz
    Apr 8, 2017 at 21:42
  • Is it because I created a new page in wordpress admin?
    – Shaz
    Apr 8, 2017 at 21:44
  • 1
    you must have style.css in theme folder or link it from functions.php otherwise it won't work, try it
    – Mario
    Apr 8, 2017 at 21:48
  • I have the enqueue function is functions.php i.e. wp_enqueue_style('custom-style', get_template_directory_uri().'/css/style.css');
    – Shaz
    Apr 8, 2017 at 21:56

4 Answers 4

35

SOLUTION The solution way actually very simple. I found that it was really hard to find a good resource for the answer so I am answering here.

The style.css was missing: template: theme in the commented header i.e.

/*
 Theme Name:   samirTheme
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentyfifteen <--------------------------------------------
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fifteen-child
*/
3
  • 1
    @Rathinam sorry for late reponse. copy and paste this code into your css file
    – Shaz
    Jun 29, 2018 at 7:47
  • 1
    This is applicable only if your intention is to make a child theme of twentyfifteen. If your theme is standalone, Spencer has the answer. Oct 26, 2018 at 10:41
  • Solved my issue.
    – abu abu
    Jun 14, 2020 at 14:54
9

In order for WordPress to recognize the set of theme template files as a valid theme, the style.css file needs to be located in the root directory of your theme, not a subdirectory.

So main theme css file in root -> then enqueue a 2nd style sheet that has all the styles in it - if you want it to be in /css/

Example header of css:

/*
Theme Name: Twenty Seventeen
Theme URI: https://wordpress.org/themes/twentyseventeen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Seventeen brings your site to life with immersive featured images and subtle animations. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentyseventeen
Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

For more info read this: https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/

1
  • 1
    @Rathinam - go to the link I posted above in my answer and compare it agains what you have written. Or just copy/paste directly from wordpress and then edit the content. Jun 13, 2018 at 21:56
0

Same happened to me. I have all the necessary files (as two files only required index and style) one thing I have noticed if you have a folder for your style.css file you will get the error message as above.

So I cross-checked and even moved the and deleted the index file from the main folder.

If I delete index.php file from main folder, and place it inside the css folder it works.

I do not know why it happened. But it seems me it need an index file inside the style folder or style.css files to be placed in the main folder.

0

This error can also be caused by character encoding. For example:

$ file -I style.css
style.css: text/plain; charset=us-ascii
$ file -I style-error.css
style-error.css: text/plain; charset=utf-16le

Copying and pasting CSS code from web pages (e.g., tutorial articles) into the CSS file itself is a common cause for getting tripped up with this. If the CSS code contains special characters, sometimes the file editor will try to change the character encoding of the CSS file to accommodate for all of the characters being added.

Long after the fact when this question was asked, but hope that helps anyone else looking for an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.