• Hi everyone –

    I’m learning about custom themes, using TwentyFourteen as a reference. Right now, I have to manually add a <link> tag to my <head> in order to make sure that my style.css is loaded. When I look at the code for TwentyFourteen, however, I don’t see any place where a <link> tag is used…

    My next assumption was that the style inclusion was done using wp_head() but that doesn’t seem to be the case as my stylesheet still doesn’t show up without hard-coding a <link>.

    Can anyone tell me how TwentyFourteen includes it’s style.css file? I just want to make sure I’m using best practices.

    Thanks for your time!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Twenty Fourteen includes its stylesheet through wp_enqueue_style, although you were correct in that wp_head() is required in order for the function to execute correctly.

    Thread Starter atommac

    (@atommac)

    Thanks, stephencottontail!

    A quick search of the /twentyfourteen directory only turns up a few instances of “wp_enqueue_style”, all of which occur in the theme’s “functions.php” file and none of which are for the “style.css” file.

    Am I looking in the wrong place?

    Note: I used the extended Find tool that comes with Komodo Edit 8.5 to do a recursive search in the /twentyfourteen directory.

    function twentyfourteen_scripts() {
    	// Add Lato font, used in the main stylesheet.
    	wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
    
    	// Add Genericons font, used in the main stylesheet.
    	wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.2' );
    
    	// Load our main stylesheet.
    	wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri(), array( 'genericons' ) );
    
    	// Load the Internet Explorer specific stylesheet.
    	wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style', 'genericons' ), '20131205' );
    	wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    	}
    
    	if ( is_singular() && wp_attachment_is_image() ) {
    		wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
    	}
    
    	if ( is_active_sidebar( 'sidebar-3' ) ) {
    		wp_enqueue_script( 'jquery-masonry' );
    	}
    
    	if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
    		wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true );
    		wp_localize_script( 'twentyfourteen-slider', 'featuredSliderDefaults', array(
    			'prevText' => __( 'Previous', 'twentyfourteen' ),
    			'nextText' => __( 'Next', 'twentyfourteen' )
    		) );
    	}
    
    	wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20140319', true );
    }
    add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
    Thread Starter atommac

    (@atommac)

    Ah, I see it now… I didn’t realize that get_stylesheet_uri() existed. I’ll try using that. Thanks, all!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Inclusion of style.css’ is closed to new replies.