Soft rejection : stylesheet issue.

HI,
My theme is soft rejected, due to this reason:
3. Theme needs to properly load files. There are several functions available for getting the path: - get_template_directory(): Returns the absolute template directory path - get_template_directory_uri(): Returns the template directory URI - get_stylesheet_directory(): Returns the absolute stylesheet directory path - get_stylesheet_directory_uri(): Returns the stylesheet directory URI.

see: http://justintadlock.com/archives/2010/11/17/how-to-load-files-within-wordpress-themes
Example(s) from your code and there are more: http://envato.d.pr/6Azb/5r6V3VdO

Can someone guide me, what is wrong with my method of including styleheets?

Thanks.
Asad Sajjad

there is nothing wrong with your code BUT it’s not the recommended way to do it … it’s better to use get_template_directory_uri as that will always get the assets from the parent theme rather than the current theme e.g. a child theme.

Lets say I build a child theme on your theme, using stylesheet_directory_uri the css from the main theme won’t be loaded, so by all purposes my child theme won’t work as it was intended.

Perfect!
Understood, Thanks for the quick reply.
Yes, I think this is the reason why its been highlighted.

I have now done something like this, please guide me is this is the correct way? I also have now included other optional parameters.
wp_enqueue_style( ‘style’, get_stylesheet_uri() );
wp_enqueue_style(‘resetstyle’, get_template_directory_uri() . ‘/css/reset.css’,false,‘1.1’,‘all’);
wp_enqueue_style(‘pluginsstyle’, get_template_directory_uri() . ‘/css/plugins.css’,false,‘1.1’,‘all’);
wp_enqueue_style(‘colorstyle’, get_template_directory_uri() . ‘/css/color.css’,false,‘1.1’,‘all’);

Yep that should be fine BUT I would personally prefix your css names e.g.

change colorstyle to mytheme_colorstyle as (although unlikely) a plugin could try and register a css file with the same name, prefixing something unique stops the chances of it happening

1 Like

You mean like this:
wp_enqueue_style(‘mytheme_colorstyle’, get_template_directory_uri() . ‘/css/color.css’,false,‘1.1’,‘all’);

Or you also are referring to renaming the sylesheet itself too?

like this:
wp_enqueue_style(‘mytheme_colorstyle’, get_template_directory_uri() . ‘/css/mytheme_color.css’,false,‘1.1’,‘all’);

just the colorstyle part, the file name won’t matter as it will be in a different file folder than anything registered with a plugin

I also have done as you suggested.

Thanks you for all the help.

Blessings,
Asad Sajjad

so, using get_stylesheet_uri() is now forbidden?

no, it can be used when in the context it was built for, but in most cases you should be using get_theme_directory_uri()

Yes as mentioned by @Gareth_Gillmam, its best to use “get_template_directory_uri()” because you also need to think in context of child theme. when i used “get_template_directory_uri()” it resolved the issues with themeforest rejection.

well, that’s weird that I got soft reject regarding to this issue.
My theme is using get_theme_directory_uri() to load all .js and .css files. Only the theme’s style.css using get_stylesheet_uri()