Support » Themes and Templates » Best way to add theme's stylesheet? Two options

  • Resolved cmegown


    Hi everyone,

    Which way is best to load the theme’s main style.css? There are two options that work:

    1) Code directly into the <head>

    <link rel="stylesheet" href="<?php get_stylesheet_uri(); ?>" />

    2) or enqueue it via functions.php

    function add_stuff() {
        wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
    add_action( 'wp_enqueue_scripts', 'add_stuff' );

    I’ve tried both and they both work. Coding it into <head> seems to work just fine, but doing it via functions.php applies an additional id to the generated <link /> as well as appends ?ver=3.6 to the end of the stylesheet path. All together, the generated link looks like this:

    <link rel="stylesheet" id="theme-style-css" href="http://localhost/themedev/wp-content/themes/test/style.css?ver=3.6" type="text/css" media="all">

    Is the version number not a security risk, even if a minor one? I guess I’m just really curious about the pros or cons…or if it truly doesn’t matter in the slightest.

  • The topic ‘Best way to add theme's stylesheet? Two options’ is closed to new replies.