Mattias
Mattias

Reputation: 11

Wordpress theme from scratch

I'm trying to develop a wordpress theme from scratch, but I have som problem with function.php. I want to add additional style scripts like bootstrap and animate.css, but the thing is that they are not loading with the "package" and when I check the links I get style.css before my css folder. If I remove style.css I can se my file in my browser. How do I solve this problem? To remove style.css from the links.

http://localhost/humlan/wp-content/themes/humlan/style.css/css/bootstrap.min.css?ver=3.0.3'

THIS IS CODE IN FUNCTION.PHP

/**
 * Enqueue scripts and styles.
 */
function humlan_scripts() {
wp_enqueue_style( 'bootstrap.min', get_stylesheet_uri() . '/css/bootstrap.min.css',false,'3.0.3','all');
wp_enqueue_style( 'prettyPhoto', get_stylesheet_uri() . '/css/prettyPhoto.css',false,'1.1','all');
wp_enqueue_style( 'font-awesome.min', get_stylesheet_uri() . '/css/font-awesome.min.css',false,'1.1','all');
wp_enqueue_style( 'animate', get_stylesheet_uri() . '/css/animate.css',false,'1.1','all');
wp_enqueue_style( 'main', get_stylesheet_uri() . '/css/main.css',false,'1.1','all');
wp_enqueue_style( 'responsive', get_stylesheet_uri() . '/css/responsive.css',false,'1.1','all');
wp_enqueue_style( 'humlan-style', get_stylesheet_uri() );


    wp_enqueue_script( 'humlan-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );

    wp_enqueue_script( 'humlan-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }
}

add_action( 'wp_enqueue_scripts', 'humlan_scripts' );

Upvotes: 0

Views: 159

Answers (2)

stevenkellow
stevenkellow

Reputation: 75

Use get_stylesheet_directory_uri() - as that returns the folder of your stylesheet. What you're using returns the URI of the actual stylesheet.

Upvotes: 0

Dhruvang Gajjar
Dhruvang Gajjar

Reputation: 598

Try This

function load_styles(){
   wp_enqueue_script( 'jQuery-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js');
   wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', array('jquery'), '3.3.7', true );
}

Instead of loading css from your server, use CDN links that are comparatively faster...

Upvotes: 0

Related Questions