Am using the WP Offload S3 plugin and not able to offload the CSS and JS files within the themes folder. Am trying to use wp_enqueue_style() like below in wp-content/themes/spark/functions.php

wp_enqueue_style( 'validationEngine.jquery', get_template_directory_uri() . '/assets/css/validationEngine.jquery.css', array(), false, 'screen' );
wp_enqueue_style( 'main', get_template_directory_uri() . '/assets/css/main.css', array(), false, 'screen' );

Am not able to offload the files. Please let me know what am I missing here.

Regards, AG

  • Did you actually use wp_dequeue_style() ( see codex ) before you enqueued the styles again, or are these own created css files? Btw please use get_stylesheet_directory_uri for a child theme.
    – Charles
    Jun 29, 2016 at 14:18
  • @Charles: So I tried the child theme way. By reading the documentation I got to know that we have to edit any theme files then edit them in child theme. Assuming this is correct? I followed this codex.wordpress.org/Child_Themes and created the functions.php So if we have to enqueue any files, should that be done in child themes functions.php instead of the parent functions.php?
    – Maga
    Jun 29, 2016 at 19:51
  • Yes, every change you wish to make you will do in the child theme folder. Now add all your own functions in the child theme functions.php. Wish to change some in a parent template file? Copy that file into child theme folder and make there your changes. This way you can be sure that when updated(by author) your changes still remain save in the child theme files. Note read always change log files(of the parent theme) before you update a parent theme, to be sure it won't interfere with your own function(s) in the child theme.
    – Charles
    Jun 29, 2016 at 23:41
  • @Charles: I did make all the changes but when I preview the site with the child theme the pages looks odd without any CSS. Basically it's not find all the CSS files. In my child theme folder I just have 2 files... style.css which is kind of empty and the other is functions.php which has small function.
    – Maga
    Jun 30, 2016 at 2:57
  • On codex : do a search for If it is not, you will need to enqueue it as well. the function you see directly after that you have to add to your functions.php (in the child theme folder). This will take care for loading the parent style.css and your changes made in your child theme style.css (if made any). But thats all I can say(This is kinda off-topic when it is about your question) about how to use child theme.
    – Charles
    Jun 30, 2016 at 3:06

1 Answer 1


Are you using a child theme?

Is get_template_directory_uri() function returning the correct URL?

My suggestion is to use get_stylesheet_directory_uri() instead.

wp_enqueue_style( 'validationEngine.jquery', get_stylesheet_directory_uri() . '/assets/css/validationEngine.jquery.css', array(), false, 'screen' );
wp_enqueue_style( 'main', get_stylesheet_directory_uri() . '/assets/css/main.css', array(), false, 'screen' );
  • I don't know what a child theme is but this the file that am editing - wp-content/themes/spark/functions.php I tried using get_stylesheet_directory_uri() instead before but no luck. Also how do I check if get_stylesheet_directory_uri() is returning the correct URL?
    – Maga
    Jun 28, 2016 at 20:48
  • Do you see the js In the view source of the page? Do you have the required addon in your site? https://deliciousbrains.com/wp-offload-s3/doc/assets-addon/
    – Pabamato
    Jun 28, 2016 at 21:53
  • @Maga, please read following. Everything you add/edit in a parent theme (as it seems you are doing) will be gone after the next theme update. Create first a child theme and make all your changes in the specific files you want (or create own plugins) so they are "save" and not changed after a theme update.
    – Charles
    Jun 29, 2016 at 0:02
  • @Pabamato: Yes I do see those 2 CSS files in the view source but their URL is not S3, its getting served from EC2. Which JS file are you referring to? Yes, we have a Licensed version of the Asset addon installed via WordPress plugin page. However we are having proxy issues while activating the License but that's a different issue. Am assuming that is not causing any issue to wp_enqueue_style().
    – Maga
    Jun 29, 2016 at 4:04
  • @Charles: Sure, ill try the child theme way. Are you saying that its a best practice while am editing any theme files OR you are saying this will resolve my issue??
    – Maga
    Jun 29, 2016 at 4:04

Your Answer

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

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