The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WP separate css files?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #205445


    my functions.php file has something to the effect of


    which will then append those css files to the queue to be added to the header.

    I just wanted to know if I’m better off putting everything into a single file or leaving it as is.

    I like not having to add the body’s id to my selectors since if I’m not reading archive.php, I’m not loading archive.css, so there isn’t a conflict there, but I realize that if a user access my page.php they will load page.css if they haven’t already.

    Can anyone shed some light on my situation and/or add any links to some useful information?

    much would be appreciated..

    btw, my real code is as follows

    add_action('wp_enqueue_scripts', function(){
      $styles = ['reset', 'styles', 'navigation'];
      $scripts = ['easing', 'sticky', 'script'];
    if(logged_in()){push($styles, 'admin');push($scripts, 'admin');}
      if(is_home())push($styles, 'home');
      if(is_single()){push($styles, 'item');push($scripts, 'item');}
      if(is_archive())push($styles, 'category');
      push($styles, 'media-queries');
      if(is_page('Contact')){push($styles, 'contact');push($scripts, 'contact');}
      if(is_page('All Items'))push($styles, 'all');
      if(is_page('Cart')){push($styles, 'cart');push($scripts, 'cart');}
    $css_dir = 'css';
      $js_dir = 'js';
      $stylesheet_dir = get_stylesheet_directory_uri();
    foreach($styles as $name => $style){
        if(is_int($name))$name = $style;
        wp_enqueue_style($name, "$stylesheet_dir/$css_dir/$style.css");
    foreach($scripts as $name => $script){
        if(is_int($name))$name = $script;
        wp_enqueue_script($name, "$stylesheet_dir/$js_dir/$script.js", array(), '1.0.0', true);
Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.