WordPress @import or enqueue and does this code make sense?

Just discovered that @import isn’t the most efficient way of importing stylesheets experimenting with enqueue. Does this make sense, trying to import several parent stylesheets in various folders:

<?php
/**
 * Load the style sheet from the parent theme.
 *
 */
function theme_name_parent_styles() {

  // Enqueue the parent stylesheet
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/style.css', array(), '0.1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/custom-admin-style.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/flexslider.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/thumbfx.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/dynamic-css/options.css', array(), '1', 'all' );


  // Enqueue the parent rtl stylesheet
  if ( is_rtl() ) {
    wp_enqueue_style( 'theme-name-parent-style-rtl', get_template_directory_uri() . '/rtl.css', array(), '0.1', 'all' );
  }

}
add_action( 'wp_enqueue_scripts', 'theme_name_parent_styles' );
?>

Related posts

Leave a Reply

1 comment

  1. First rule: follow the wordpress codex

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
    function enqueue_child_theme_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style')  );
    }
    

    Next time I will check the source first.

    Solved, thanks for the troubleshoot @m1ro.