• Resolved The Dro

    (@desaad37)


    Is it possible to add HTML comments above styles that are registered and enqueued?

    I tried doing it like this but it ends up adding the comment above the whole list of styles instead of just above the font style additions.

    // Load styles
    function techpro_styles()
    {
        wp_register_style('normalize', get_template_directory_uri() . '/normalize.css', array(), '1.0', 'all');
        wp_enqueue_style('normalize'); 
    
        wp_register_style('techpro', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
        wp_enqueue_style('techpro'); 
    
    	 $marker = '<!-- Google Fonts -->';
    	 echo "\n${marker}\n";
    
    	wp_register_style('opensans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800');
        wp_enqueue_style('opensans');
    
    	wp_register_style('lato', '//fonts.googleapis.com/css?family=Lato:400,300,400italic,700,300italic');
        wp_enqueue_style('lato'); 	
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • wp_enqueue_scripts is for queuing scripts only, not adding custom messages and markup comments I think. You could use wp_head instead, as you want to include the HTML comment:

    function techpro_styles() {
    	?>
    	<!-- Google Fonts -->
    	<link rel="stylesheet" id="opensans" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800?ver=<?php echo get_bloginfo('version'); ?>" type="text/css" media="all" />
    	<link rel="stylesheet" id="lato" href="//fonts.googleapis.com/css?family=Lato:400,300,400italic,700,300italic?ver=<?php echo get_bloginfo('version'); ?>" type="text/css" media="all" />
    	<?php
    }
    add_action('wp_head', 'techpro_styles');
    Thread Starter The Dro

    (@desaad37)

    Thanks, that makes perfect sense. I appreciate the help!

    You’re welcome, glad it helped ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding comments above Enqueued Styles’ is closed to new replies.