WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How To Add Multiple CSS files in your wordpress theme? (6 posts)

  1. Krushna Ghodke
    Member
    Posted 1 year ago #

    Actually i am converting my static HTML/CSS theme into WordPress theme for my project so, theme are multiple CSS files in the css folder so how to add multiple CSS to wordpress theme?

  2. aritzalvarez
    Member
    Posted 1 year ago #

    you need have a main CSS file in the main wordpress theme directory and it named as

    style.css

    and call it as

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />

    it's a condition needed to wordpress allows you to use as theme.

    but, once done it you can call som many CSS files as you need by...

    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/address-to-css-file.css" type="text/css" media="screen" />

    Please, notice than function

    <?php bloginfo('template_directory'); ?>

    prits you wordpress template directory withou the ending slash, so you need add it

  3. David Laietta
    Member
    Posted 1 year ago #

    Additionally, you can import new CSS files in your main stylesheet through imports.

    After you have your main style.css file loading, you can tell that stylesheet to load additional CSS files, based on a relative location. Since that file has to be in the main folder of your theme, let's say you have others in a css folder in the theme. Your imports would then look like this:

    /* Stylesheet comments here */
    
    @import url('css/slider.css');
    @import url('css/colors.css');

    Based on the names of your files and the folders that they are in. This gives you the added bonus of being able to control load order for cascading styles.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    also review http://codex.wordpress.org/Function_Reference/wp_enqueue_style for how to enqueue stylesheets.

  5. Krushna Ghodke
    Member
    Posted 1 year ago #

    Thank You All :)

  6. gunalan87
    Member
    Posted 9 months ago #

    Reference will be useful anyone who doesn't know how to add CSS and JS files through functions.php

Topic Closed

This topic has been closed to new replies.

About this Topic